gpt4 book ai didi

html - bootstrap 4 固定导航栏有 2 行,第一行居中品牌形象

转载 作者:太空宇宙 更新时间:2023-11-04 01:03:07 25 4
gpt4 key购买 nike

请告诉我,如何创建 2 行的 bootstrap 4 固定导航栏,第一行居中品牌形象,如 https://www.newyorker.com/ (向下滚动后更改图像大小)和第二行的导航菜单?谢谢!

最佳答案

检查这个 working example :)

如果您在 stackoverflow 中查看示例,请查看完整页面:)

$(window).scroll(()=>{
let distance = $('#header').offset().top;
if(distance > 150){
$('#logo').addClass('header-image-scroll');
$('#nav-collection').addClass('navbar-scroll');
}
else {
$('#logo').removeClass('header-image-scroll');
$('#nav-collection').removeClass('navbar-scroll');
}
})
#header {
height: 120px;
}

#nav-collection {
transition: margin 300ms ease-in-out;
font-size: .80rem;
}

#nav-collection li {
padding: 5px;
margin-right: 30px;
}

#logo{
height: 80%;
width: auto;
transition: transform 300ms ease-in-out;
}

.header-image-scroll{
transform: scale(0.7);
}

.navbar-scroll {
margin-top: -25px;
}

.content {
height: 100vh;
}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

<nav class="navbar navbar-expand-md navbar-light sticky-top bg-white">
<div class="container-fluid p-0">
<button class="navbar-toggler my-2" type="button" data-toggle="collapse" data-target="#navbarCollapse">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse flex-column align-items-center text-center ml-lg-2 ml-0" id="navbarCollapse">
<ul class="navbar-nav flex-row mb-md-1 mt-md-0 mb-3 mt-2">
<li class="nav-item">
<div id="header" class="d-flex align-items-center justify-content-center">
<img src="https://logos-download.com/wp-content/uploads/2016/11/The_New_Yorker_logo.png" id="logo">
</div>
</li>
</ul>
<ul class="navbar-nav justify-content-center w-100 border-top border-bottom font-weight-bold" id="nav-collection">
<li class="nav-item active">
<a class="nav-link" href="#">News</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Culture</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Books</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Business & Tech</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Humor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Cartoons</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Magazine</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Video</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Podcasts</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="content"></div>

关于html - bootstrap 4 固定导航栏有 2 行,第一行居中品牌形象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52776935/

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