我想问你为什么要在顶部固定滚动导航栏时出现白色缝隙?你们在这种情况下有什么建议吗?菜单应显示在背景图像上。我试图用背景做些什么,但这没有帮助。
这是差距的照片: https://ibb.co/RcvM5nS
这是代码:
.background {
background-color: #000000;
background-repeat: no-repeat;
background-size: cover;
background-position: center;
height: 650px;
width: 100%;
}
/*menu*/
#siteNav {
margin: 0 auto;
position: fixed;
width: 100%;
height: 50px;
box-sizing: border-box;
top: 0;
left: 0;
transition: 0.3s;
}
#siteNav.scroll {
background: rgba(0, 0, 0, 0.8);
height: 80px;
padding: 10px 80px;
}
#siteNav .logo {
padding: 10px;
height: 40px;
float: left;
transition: 0.3s;
}
#siteNav ul {
list-style: none;
float: right;
margin: 0;
padding: 0;
display: flex;
}
#siteNav ul li {
list-style: none;
}
#siteNav ul li a {
line-height: 50px;
padding: 6px 30px;
text-decoration: none;
transition: 0.3s;
color: #ffffff;
}
#siteNav.scroll ul li a {
color: #000000;
}
#siteNav ul li a:focus {
outline: none;
}
<nav id="siteNav">
<img class="logo" src="images/img2-logo.png" alt="">
<ul>
<li><a href="#mission">MISSION</a></li>
<li><a href="#clients">CLIENTS</a></li>
<li><a href="#products">PRODUCTS</a></li>
<li><a href="#contact">CONTACT</a></li>
</ul>
</nav>
<!--header-->
<div class="background">
<header>
<div>
<h1><br><a></a></br>
</h1>
</div>
</header>
</div>
答案 0 :(得分:0)
在df8 = df8.apply(lambda x: pd.Series(x.dropna().values))
print (df8)
rule_id 50014 50238 50239 50356 50412 51181 53139
0 100.0 100.0 100.0 100.0 100.0 100.0 100.0
1 100.0 NaN NaN NaN NaN NaN NaN
下面的padding: 6em 0 3em;
中添加<div>
摆脱<nav>
代码段采用第一个解决方案
<h1>
.background {
background-image: url('https://via.placeholder.com/150');
background-repeat: no-repeat;
background-size: cover;
background-position: center;
height: 650px;
width: 100%;
padding: 6em 0 3em;
}
/*menu*/
#siteNav {
margin: 0 auto;
position: fixed;
width: 100%;
height: 50px;
box-sizing: border-box;
top: 0;
left: 0;
transition: 0.3s;
}
#siteNav.scroll {
background: rgba(0, 0, 0, 0.8);
height: 80px;
padding: 10px 80px;
}
#siteNav .logo {
padding: 10px;
height: 40px;
float: left;
transition: 0.3s;
}
#siteNav ul {
list-style: none;
float: right;
margin: 0;
padding: 0;
display: flex;
}
#siteNav ul li {
list-style: none;
}
#siteNav ul li a {
line-height: 50px;
padding: 6px 30px;
text-decoration: none;
transition: 0.3s;
color: #000000;
}
#siteNav.scroll ul li a {
color: #000000;
}
#siteNav ul li a:focus {
outline: none;
}
答案 1 :(得分:0)
问题出在h1
边距顶部。删除它,它将起作用。
另外,我建议您使用<header>
标签作为包含导航的第一级标签。
无论如何,这是解决方案。
我在正文中添加了margin:0
,因为这里的默认边距为8px
.background {
background-color: #000000;
background-repeat: no-repeat;
background-size: cover;
background-position: center;
height: 650px;
width: 100%;
}
/*menu*/
#siteNav {
margin: 0 auto;
position: fixed;
width: 100%;
height: 50px;
box-sizing: border-box;
top: 0;
left: 0;
transition: 0.3s;
}
#siteNav.scroll {
background: rgba(0, 0, 0, 0.8);
height: 80px;
padding: 10px 80px;
}
#siteNav .logo {
padding: 10px;
height: 40px;
float: left;
transition: 0.3s;
}
#siteNav ul {
list-style: none;
float: right;
margin: 0;
padding: 0;
display: flex;
}
#siteNav ul li {
list-style: none;
}
#siteNav ul li a {
line-height: 50px;
padding: 6px 30px;
text-decoration: none;
transition: 0.3s;
color: #ffffff;
}
#siteNav.scroll ul li a {
color: #000000;
}
#siteNav ul li a:focus {
outline: none;
}
h1 {
margin-top:0;
}
body {
margin:0
}
<nav id="siteNav">
<img class="logo" src="images/img2-logo.png" alt="">
<ul>
<li><a href="#mission">MISSION</a></li>
<li><a href="#clients">CLIENTS</a></li>
<li><a href="#products">PRODUCTS</a></li>
<li><a href="#contact">CONTACT</a></li>
</ul>
</nav>
<!--header-->
<div class="background">
<header>
<div>
<h1><br /><a></a>
</h1>
</div>
</header>
</div>
答案 2 :(得分:-1)
我认为您在HTML代码中使用了<h1>
标签,并且其中设置了默认边距。如果您能解决问题,它将解决您的问题。