gpt4 book ai didi

jquery - Css - 将子菜单 div 扩展到父级?

转载 作者:太空宇宙 更新时间:2023-11-04 09:12:02 25 4
gpt4 key购买 nike

我有一个包含子项的下拉菜单。我可以显示完整的子菜单,但在子菜单 div 内容中删除了一些点,我无法使其完整显示。我在底部的这张图片中对此进行了解释。因此子菜单 div 需要扩展左侧的其他列。

.menu {
list-style:none;
}
.item {
display:inline-block;
height:50px;
}
.item a {
text-decoration:none;
padding:20px;
display:inline-block;
color:#333333;
font-size:14px;
border-right:1px #ebedf0 solid;
}
.item a:hover {
text-decoration:none;
background-color:#f0f3f7;
}
.menu li:hover > a {
background-color:#f0f3f7;
}
.item .sub {
display:none;
width: 100%;
padding:0 1000em;
margin:0 -1000em;
height:200px;
position:absolute;
background-color:#f0f3f7;
z-index:1;
box-shadow:0px 6px 20px -8px #999999;
}
.item:hover .sub {
margin-top:2px;
display:block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="col-lg-2 col-md-6 logo">
<a href="index.php" title="Anasayfa"><img src="images/logo.png" alt="Logo" width="170" height="55" /></a>
</div>
<div class="col-lg-7 visible-lg hidden-xs">

<ul class="menu">
<li class="item">
<a href="index.php" title="Anasayfa">Anasayfa</a>
</li>
<li class="item">
<a href="#" title="Kategoriler">Kategoriler <i class="fa fa-caret-down"></i></a>
<div class="sub">
<div style="width:1000px;">
cat
</div>
</div>
</li>
<li class="item">
<a href="#" title="Geliştirme">Geliştirme</a>
</li>
<li class="item">
<a href="#" title="Dosyalar">Dosyalar <i class="fa fa-caret-down"></i></a>
<div class="sub">
dosyalar
</div>
</li>
</ul>
</div>
<div class="col-lg-2 visible-lg">
Search
</div>
</div>

最佳答案

如果我对您的理解正确,下面的代码应该可以解决您的问题。 .item .sub 上的填充和边距值是罪魁祸首。我还添加了 left: 0px 使其左对齐。

.item .sub {
display: none;
width: 100%;
padding: 0;
margin: 0;
height: 200px;
position: absolute;
background-color: #f0f3f7;
z-index: 1;
box-shadow: 0px 6px 20px -8px #999999;
left: 0px;
}

关于jquery - Css - 将子菜单 div 扩展到父级?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42061243/

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