gpt4 book ai didi

javascript - 我怎样才能让标志不超过固定的导航栏?

转载 作者:行者123 更新时间:2023-11-28 14:34:18 28 4
gpt4 key购买 nike

如何让 Logo 不超过固定的导航栏?正如您在图像中看到的那样, Logo 越过固定的导航栏。如何使 div 不受固定导航栏的影响?无论如何,您是否可以让它不超过导航栏。当 Logo 位于导航栏前面时,您会在下面看到图像。 image

.content {
width: 94%;
margin: 4em auto;
font-size: 20px;
line-height: 30px;
text-align: justify;
}

.logo {
line-height: 60px;
position: fixed;
float: left;
margin: 16px 46px;
color: #fff;
font-weight: bold;
font-size: 20px;
letter-spacing: 2px;
}

nav {
position: fixed;
width: 100%;
line-height: 60px;
}

nav ul {
line-height: 60px;
list-style: none;
background: rgba(0, 0, 0, 0);
overflow: hidden;
color: #fff;
padding: 0;
text-align: right;
margin: 0;
padding-right: 40px;
transition: 1s;
}

nav.black ul {
background: #fff;
}

nav ul li {
display: inline-block;
padding: 16px 40px;;
}

nav ul li a {
font-family: 'Josefin Sans', sans-serif;
font-size: 14px;
color: #000;
font-weight: 600;
text-transform: uppercase;
text-decoration: none;
}

.menu-icon {
line-height: 60px;
width: 100%;
background: #000;
text-align: right;
box-sizing: border-box;
padding: 15px 24px;
cursor: pointer;
color: #fff;
display: none;
}
.slide-right {
display: block;
left: 30%;
right:50%;
top: 25%;
position: absolute;
-webkit-animation: slide-right 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
animation: slide-right 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}
.image-desc {
width: 750px;
height: 100px;
left: 17%;
right:50%;
position: absolute;
top: 55%;
color: #fff;
}
.image-desc h1 {
font-family: 'Josefin Sans', sans-serif;
font-size: 30px;
font-weight: 300;
color: #555;
-webkit-animation: slide-right 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
animation: slide-right 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}
<header>
<nav>
<div class="menu-icon">
<i class="fa fa-bars fa-2x"></i>
</div>
<div class="logo">
<img src="/TeknikSnabben/assets/image/logo.png">
</div>
<div class="menu">
<ul>
<li><a href="#">START</a></li>
<li><a href="#">TJĂ„NSTER</a></li>
<li><a href="#">OM OSS</a></li>
<li><a href="#">KONTAKT</a></li>
</ul>
</div>
</nav>
<div class="slide-right" >
<img src="/TeknikSnabben/assets/image/logo2.png">
</div>
<div class="image-desc"><h1> VI HJÄLPER DIG MED DIN TEKNIK I HEMMET </h1>
</header>

最佳答案

给你的 nav 一个更高的 z-index 和一个背景色:

nav {
position: fixed;
width: 100%;
line-height: 60px;
z-index: 10;
background-color: white;
}

.content {
width: 94%;
margin: 4em auto;
font-size: 20px;
line-height: 30px;
text-align: justify;
}

.logo {
line-height: 60px;
position: fixed;
float: left;
margin: 16px 46px;
color: #fff;
font-weight: bold;
font-size: 20px;
letter-spacing: 2px;
}

nav {
position: fixed;
width: 100%;
line-height: 60px;
z-index: 10;
background-color: white;
}

nav ul {
line-height: 60px;
list-style: none;
background: rgba(0, 0, 0, 0);
overflow: hidden;
color: #fff;
padding: 0;
text-align: right;
margin: 0;
padding-right: 40px;
transition: 1s;
}

nav.black ul {
background: #fff;
}

nav ul li {
display: inline-block;
padding: 16px 40px;
;
}

nav ul li a {
font-family: 'Josefin Sans', sans-serif;
font-size: 14px;
color: #000;
font-weight: 600;
text-transform: uppercase;
text-decoration: none;
}

.menu-icon {
line-height: 60px;
width: 100%;
background: #000;
text-align: right;
box-sizing: border-box;
padding: 15px 24px;
cursor: pointer;
color: #fff;
display: none;
}

.slide-right {
display: block;
left: 30%;
right: 50%;
top: 25%;
position: absolute;
-webkit-animation: slide-right 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
animation: slide-right 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}

.image-desc {
width: 750px;
height: 100px;
left: 17%;
right: 50%;
position: absolute;
top: 55%;
color: #fff;
}

.image-desc h1 {
font-family: 'Josefin Sans', sans-serif;
font-size: 30px;
font-weight: 300;
color: #555;
-webkit-animation: slide-right 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
animation: slide-right 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}
<header>
<nav>
<div class="menu-icon">
<i class="fa fa-bars fa-2x"></i>
</div>
<div class="logo">
<img src="https://picsum.photos/80/80">
</div>
<div class="menu">
<ul>
<li><a href="#">START</a></li>
<li><a href="#">TJĂ„NSTER</a></li>
<li><a href="#">OM OSS</a></li>
<li><a href="#">KONTAKT</a></li>
</ul>
</div>
</nav>
<div class="slide-right">
<img src="https://picsum.photos/200/200">
</div>
<div class="image-desc">
<h1> VI HJÄLPER DIG MED DIN TEKNIK I HEMMET </h1>
</div>
</header>

关于javascript - 我怎样才能让标志不超过固定的导航栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53732455/

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