CSS 下拉导航

CSS drop down navigation(CSS 下拉导航)
本文介绍了CSS 下拉导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定这是我缺少的一些简单的东西...我的下拉菜单正在主导航中打开,并扩大了它.这是我正在处理的页面的链接.问题在于应用按钮下方的导航.

I'm sure this is something simple I'm missing... My drop down menu is opening within the main navigation, widening it. Here is a link to the page I'm working on. The issue is with the navigation below the App buttons.

http://membershq.incentiveusa.com/AwardPages/GoalUp_Test2/index_test3.html#

这是我的 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 >
    <li><a href="#">About Us</a>
    <ul>
    <li><a href="about.html">Who We Are</a></li>
    <li><a href="news.html">News</a></li>
    </ul></li>
    <li><a href="HowItWorks.html">How It Works</a></li>
    <li><a href="FactsStats.html">Facts</a></li>
    <li><a href="ParentingTools.html">Tools</a></li>
    <li><a href="testimonials.html">Testimonials</a></li>
    <li><a href="news.html">News</a></li>
    <li><a href="awards.html">Brand Name Awards</a></li>
    <li><a href="contact.html">Contact</a></li>
</ul>

这是 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: 10000;
text-align:center;
}

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

}

/*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;
z-index: 10001;
}

/*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;
z-index: 10001;
}

/*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;

}

推荐答案

你要给选择器添加一个 position:absolute .navigation li ul

You have to add a position:absolute to the selector .navigation li ul

.navigation{
margin-right: auto;
margin-left: auto;
width: 100%;
background-color: #0f9cde;
position: absolute;
display: block;
margin-bottom: 15px;
z-index: 1000;
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: 10000;
text-align:center;
}

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

}

/*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;
z-index: 10001;
}

/*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;
z-index: 10001;
  
  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;

}

<div class="container-fluid">
         <div class="section-title2 text-center">        
                <div class="navigation">
<ul >
    <li><a href="#">About Us</a>
    <ul>
    <li><a href="about.html">Who We Are</a></li>
    <li><a href="news.html">News</a></li>
    </ul></li>
    <li><a href="HowItWorks.html">How It Works</a></li>
    <li><a href="FactsStats.html">Facts</a></li>
    <li><a href="ParentingTools.html">Tools</a></li>
    <li><a href="testimonials.html">Testimonials</a></li>
    <li><a href="news.html">News</a></li>
    <li><a href="awards.html">Brand Name Awards</a></li>
    <li><a href="contact.html">Contact</a></li>
</ul>
                  </div></div></div>

这篇关于CSS 下拉导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

how to remove this error quot;Response must contain an array at quot; . quot;.quot; while making dropdown(如何删除此错误quot;响应必须在quot;处包含数组。创建下拉菜单时(Q;))
Why is it necessary to use `document.createElementNS` when adding `svg` tags to an HTML document via JS?(为什么在通过JS为一个HTML文档添加`svg`标签时,需要使用`Document.createElementNS`?)
wkhtmltopdf print-media-type uses @media print ONLY and ignores the rest(Wkhtmltopdf print-media-type仅使用@media print,而忽略其余内容)
price depend on selection of radio input(价格取决于无线电输入的选择)
calculate price depend on selection without button(根据没有按钮的选择计算价格)
What should I consider before minifying HTML?(在缩小HTML之前,我应该考虑什么?)