gpt4 book ai didi

html - CSS 移动导航菜单 - 下拉菜单嵌套不正确

转载 作者:行者123 更新时间:2023-11-28 07:38:02 24 4
gpt4 key购买 nike

我希望我解释清楚了。您可以在以下位置查看我的网站:http://membershq.incentiveusa.com/AwardPages/GoalUp_Test2/index_test2.html

导航菜单,当采用移动格式时,在主导航顶部有下 zipper 接,而不是嵌套在主导航中并将其余链接向下推。

CSS:

.navigation{
margin-right: auto;
margin-left: auto;
width: 100%;
background-color: #0f9cde;
position: absolute;
display: block;
margin-bottom: 15px;
z-index: 1000;
top: 735px;
margin-left: -15px;
}
/*Strip the ul of padding and list styling*/
.navigation ul{
list-style-type: none;
margin: 0 auto;
padding: 0;
position: relative;
z-index: 1000;
text-align:center;



}

/*Create a horizontal list with spacing*/
.navigation li{
display:inline-block;
margin-right: 0px;
background-color:#0f9bde;
vertical-align: top;
}

/*Style for menu links*/
.navigation li a {

min-width: 189px;
height: 50px;
text-align: center;
line-height: 50px;
font-family: 'Maven Pro', sans-serif;
font-size:18px;
color: #fff;
width:100%;
background-color: #0f9cde;
text-decoration: none;
display:block;

}

/*Hover state for top level links*/
.navigation li:hover a {
color: #f7a800;
text-decoration: underline;
}

/*Style for dropdown links*/
.navigation li:hover ul a {
background: #f7a800;
color: #ffffff;
height: 40px;
line-height: 40px;

}

/*Hover state for dropdown links*/
.navigation li:hover ul a:hover {
background: #fff;
color: #f7a800;
}

/*Hide dropdown links until they are needed*/
.navigation li ul{
display: none;
position: absolute;
}

/*Make dropdown links vertical*/
.navigation li ul li {
display: block;
float: none;
}

/*Prevent text wrapping*/
.navigation li ul li a {
width: auto;
min-width: 100px;
padding: 0 20px;
}

.navigation ul li:hover ul{
display:block;
}

/*Display the dropdown on hover*/
.navigation ul li a:hover {
display: block;

}



/*Style 'show menu' label button and hide it by default*/
.show-menu {
font-family:'Maven Pro', sans-serif;
text-decoration: none;
color: #fff;
background: #f7a800;
text-align: center;
padding: 10px 0;
display: none;
}

/*Hide checkbox*/
input[type=checkbox]{
display: none;
-webkit-appearance: none;
}

/*Show menu when invisible checkbox is checked*/
input[type=checkbox]:checked ~ #menu{
display: block;
}

#menu ul {min-width: 189px; }

/*Responsive Styles*/

@media screen and (max-width : 975px){
/*Make dropdown links appear inline*/
.navigation ul {
position: static;
display: none;
}
/*Create vertical spacing*/
.navigation li {
margin-bottom: 1px;
}
/*Make all menu links full width*/
.navigation ul li, li a {
width: 100%;
}
.navigation li ul li {
width: 100%;
}
#menu ul {min-width: 100%;}
/*Display 'show menu' link*/
.show-menu {
display:block;
}
}

这是 HTML:

<div class="container-fluid">
<div class="section-title2 text-center">
<div class="navigation">
<label for="show-menu" class="show-menu">Show Menu</label>
<input type="checkbox" id="show-menu" role="button">
<ul id="menu">
<li>
<a href="about.html">About Us</a>
<ul>
<li>
<a href="news.html">News</a>
</li>
</ul>
</li>
<li>
<a href="HowItWorks.html">How It Works</a>
<ul>
<li>
<a href="FactsStats.html">Facts</a>
</li>
<li>
<a href="ParentingTools.html">Tools</a>
</li>
</ul>
</li>
<li>
<a href="testimonials.html">Testimonials</a>
</li>
<li>
<a href="awards.html">Brand Name Awards</a>
</li>
<li>
<a href="contact.html">Contact</a>
</li>
</ul>
</div>
</div>
</div>

最佳答案

你的问题与这种风格有关:

.navigation li ul{
display: none;
position: absolute;
}

删除 position: absolute;,可能在您的移动断点处需要。

像这样:

@media screen and (max-width : 975px){
.navigation li ul{
position: static;
}
}

关于html - CSS 移动导航菜单 - 下拉菜单嵌套不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31121388/

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