[英]How to Move Dropdown Menu Directly Under Parent Tab?
我有一个菜单,该菜单具有不错的下拉菜单,而且有所有菜单,但是我这里唯一的问题是我找不到一种方法可以将这个该死的下拉菜单向左移一点,因此它直接位于其父选项卡下! ! 它总是放在一边,我看到其他人的示例,当我在菜单选项卡之间添加填充时,它执行的操作完全相同! 也许是因为填充? (我在说这个: http : //jsbin.com/gimilapiki/edit?html,css,output )
所以,这是我的项目: https : //codepen.io/anon/pen/gxdVdO?editors=1100
这是一些代码(因为StackOverFlow迫使我这样做):
body {background-color: #E8E8E8;}
ul {list-style: none;}
li {
float: left;
background-color: white;
}
li:not(.search) {padding: 12px 20px 12px 20px;}
li ul {
display: none;
position: absolute;
padding-left: 1px;
padding-top: 12px;
}
a {
text-decoration: none;
color: #5E5E5E;
}
li:not(.search):hover {
color: black;
background-color:#E3E3E3;;
}
ul li ul li {
float: none;
background-color: #E3E3E3;
}
ul li ul li:not(.search):hover {background-color: #D1D1D1;}
li:hover > ul {
z-index: 289;
display: block;
padding: 0 10px 20 20px;
}
.search-input {
width: 150px;
height: 18px;
padding: 0 7px;
border: 1px solid grey;
border-radius: 10px;
border-bottom-right-radius: 0px;
border-top-right-radius: 0px;
}
.search-input:hover {
outline: none;
opacity:0.99;
cursor: pointer;
box-shadow: 0 2px 5px 2px rgba(0, 0, 0, 0.05) inset;
}
input:focus {outline: none;}
#search-icon {
height: 18px;
}
.search {
padding-bottom: 10px;
}
form {
margin-top: 4px;
}
我对这个简单的问题非常执着。 添加padding-left或padding-right或margins无济于事,它仅影响选项卡的垂直高度,而没有其他影响。 我尝试了所有事情,尽了最大的努力进行了研究,但没有任何效果。 请帮忙!!!
您可以添加像这样的简单内容
li ul {
display: none;
position: absolute;
padding-left: 1px;
margin-left: -10px;
padding-top: 12px;
}
我添加了margin-left: -10px;
我认为它有效
ul > li{
position: relative;
}
ul > li > ul{
position: absolute;
top: 100%;
left: 0px;
}
尝试添加此。
只需添加相对位置即可解决您的问题。
li ul { display: none; position: relative; padding-left: 1px; padding-top: 12px; margin-right:100px; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.