gpt4 book ai didi

html - 如何在 MaterializeCSS 下拉菜单中创建子菜单?

转载 作者:搜寻专家 更新时间:2023-10-31 23:23:19 24 4
gpt4 key购买 nike

我正在尝试使用 MaterializeCSS 框架在下拉菜单中添加子菜单下拉菜单。我尝试使用以下代码,但没有成功。

<!-- this the main dropdown -->
<ul id="MainDropDown" class="dropdown-content">
<li><a href="#" class="dropdown-button" data-beloworigin="true" data-contrainwidth="false" data-gutter="30" data-alignment="right" data-activates="drop1">Dropdown1<span class="right caret">&#9658;</span></a></li>
<li><a href="#" class="dropdown-button" data-beloworigin="true" data-contrainwidth="false" data-gutter="30" data-alignment="right" data-activates="drop2">Dropdown2<span class="right caret">&#9658;</span></a></li>
<li><a href="#" class="dropdown-button" data-beloworigin="true" data-contrainwidth="false" data-gutter="30" data-alignment="right" data-activates="drop3">Dropdown3<span class="right scaret">&#9658;</span></a></li>
</ul>
<ul id="drop1" class="dropdown-content">
<li><a href="#">Create</a></li>
</ul>
<ul id="drop2" class="dropdown-content">
<li><a href="#">Create</a></li>
<li><a href="#">Update</a></li>
</ul>
<ul id="drop3" class="dropdown-content">
<li><a href="#">Create</a></li>
</ul>

最佳答案

我自己也遇到了同样的问题。结果证明它就像嵌套另一个下 zipper 接一样简单,设置合适的排水沟,并确保溢出dropdown-content 设置为可见

这是在 Nested dropdowns in materialize 中链接到修改后的 jsfiddle 的链接

https://jsfiddle.net/fb0c6b5b/

$('.dropdown-button2').dropdown({
inDuration: 300,
outDuration: 225,
constrain_width: false, // Does not change width of dropdown to that of the activator
hover: true, // Activate on hover
gutter: ($('.dropdown-content').width()*3)/2.5 + 5, // Spacing from edge
belowOrigin: false, // Displays dropdown below the button
alignment: 'left' // Displays dropdown with edge aligned to the left of button
}
);
.dropdown-content{
overflow: visible !important;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/css/materialize.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a class='dropdown-button btn' href='#' data-activates='dropdown1' data-beloworigin="true">Drop Me!</a>
<ul id='dropdown1' class='dropdown-content'>
<li><a href="#!">two</a></li>
<li class="divider"></li>
<li><a href="#!">three</a></li>
<li><a class='dropdown-button2 d' href='#' data-activates='dropdown2' data-hover="hover" data-alignment="left">Drop Me!</a></li>
</ul>
<ul id='dropdown2' class='dropdown-content'>
<li><a href="#!">one</a></li>
<li><a href="#!">two</a></li>
<li class="divider"></li>
<li><a href="#!">three</a></li>
</ul>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/js/materialize.min.js"></script>

关于html - 如何在 MaterializeCSS 下拉菜单中创建子菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35980949/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com