我创建了一个下拉菜单,我试图摆脱我正在逐渐下拉之初,父组件及其子女之间的小空间,如下图所示的截图:CSS下拉落后留空(Snap Attached)如何消除空间?
我想下拉到从哪里开始标签,像这样开头:
--------
| Parent
-----------
| Child
------------
请找一个代码片段下面附:
ul {
list-style-type: none;
margin: 0;
padding-left: 25px;
padding-right: 10px;
position: absolute;
}
li {
display: inline-block;
float: left;
margin-right: 1px;
}
li a {
display: block;
min-width: 138.7px;
height: 50px;
text-align: center;
line-height: 50px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #fff;
background: #2f3036;
text-decoration: none;
padding-left: 10px;
padding-right: 10px;
}
li:hover a {
background: green;
}
li:hover ul a {
background: grey;
color: #2f3036;
height: 40px;
line-height: 40px;
text-align: center;
}
li:hover ul a:hover {
background: green;
color: #fff;
}
li ul {
display: none;
}
li ul li {
display: block;
float: none;
}
li ul li a {
width: auto;
min-width: 100px;
}
ul li a:hover+.hidden,
.hidden:hover {
display: block;
width: auto;
}
#menu {
text-align: center;
}
<ul class="menu">
<li><a href="#">Somthing</a></li>
<li> <a href="#">something</a>
<ul class="hidden">
<li><a href="#">somethoing</a></li>
<li><a href="#">something</a></li>
</ul>
</li>
</ul>
在此先感谢。
'李UL {填充左:0;}' –
我想,我是第一个)他的回答是一样的,因为我写的) –