【发布时间】:2020-09-04 20:47:59
【问题描述】:
使用导航栏上的固定位置时,如何将内容向下移动?因为我使用位置:固定,所以我的页面进入顶部。我可以使用margin-bottom,但我的导航栏并不完全位于屏幕顶部。 (是的,我在 * 内有 margin:0 和 padding:0)。
链接:https://codepen.io/Altinzzz/pen/ZEWawxV
代码
html
<div class="topnav" id="myTopnav">
<a href="websitecar.html"> Home</a>
<a href="aboutus.html" class="active"> About Us</a>
<a href="contactus.html">Contact</a>
<a href="#about">About</a>
</div>
<div class = "introduction">
<span class = "introductionText"> Welcome </span>
<span class = "introductionText2"> About us </span>
</div>
css
*{
font-family: Arial, Helvetica, sans-serif;
padding: 0;
margin: 0;
}
.topnav {
overflow: hidden;
background-color: #312E2E;
position: fixed;
width: 100%;
z-index: 2;
float: left;
}
.topnav a {
float: left;
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.introduction{
text-align:center;
padding: 0;
}
.introduction span{
display: block;
animation-fill-mode: forwards;
}
.introductionText{
font-size: 80px;
background: white;
color:black;
letter-spacing: -50px;
font-weight: 400;
position: relative;
animation: text 3s 1;
}
.introductionText2{
font-size: 40px;
background: white;
font-weight: 400;
margin-bottom: 50px;
}
【问题讨论】:
标签: html css css-position