【发布时间】:2015-08-11 20:26:07
【问题描述】:
我似乎无法将导航栏固定在顶部。看起来 position: fixed 被另一个元素阻挡,可能是伪元素之一,我不确定。
另外,自从我决定将背景颜色应用到整个 nav_wrapper 后,我的子菜单的边框半径由于某种原因消失了。
HTML:
<!-- NAV -->
<div class="nav_wrapper">
<ul class="nav">
<li><a href="#">Home</a></li>
<li><a href="#">Calandar</a></li>
<li><a href="#">About Us</a>
<ul class="sub_nav1">
<li class="the_pastor"><a href="#">The Pastor</a></li>
<li><a href="#">History</a></li>
<li class="about"><a href="#">About Byzantines</a></li>
</ul>
</li>
<li><a href="#">Mass Times</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
<div>
CSS:
.nav_wrapper ul {
display: block;
margin: 0;
padding: 0;
text-align: center;
font-size: 0;
/* remove whitespace */
min-width: 5px;
background-color: #993300;
}
.nav_wrapper ul li {
list-style: none;
display: inline-block;
vertical-align: top;
position: relative;
font-size: 20px;
/* font-size reset */
}
/* hides the submenu by default */
.nav_wrapper ul ul {
display: none;
top: 100%;
left: 0;
position: absolute;
}
/* makes the sub menu appear on hover over list element */
.nav_wrapper ul li:hover > .sub_nav1 {
display: block;
width: 100%;
}
/* lists the list items on top of one another */
.nav_wrapper ul .sub_nav1 li {
position: relative;
width: 100%;
}
.nav_wrapper ul li a {
display: block;
text-decoration: none;
color: #ffffff;
padding: 20px;
}
.nav_wrapper li a:hover {
color: #000;
background-color: #ffffff;
}
/* Dropdown Menu arrow */
.nav_wrapper ul> li > a:after {
content: '\25BE';
line-height: 0;
}
.nav_wrapper ul li > a:only-child:after {
content: '';
}
/* BORDER RADIUS'S */
.nav_wrapper ul ul .the_pastor {
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
}
.nav_wrapper ul ul .about {
border-top-right-radius: 0px;
border-bottom-right-radius: 7px;
border-bottom-left-radius: 7px;
}
【问题讨论】:
-
您如何尝试将其修复到顶部?你想要一个粘性标题?
-
不幸的是,我在您的 CSS 中找不到“位置:固定”。此外,要使边框半径起作用,您还需要指定其他边框属性,例如边框宽度和颜色。没有边框宽度,边框半径不会生效。