gpt4 book ai didi

html - 小屏幕上的 Bootstrap 导航栏没有下拉菜单

转载 作者:行者123 更新时间:2023-11-28 00:24:27 24 4
gpt4 key购买 nike

在较小的设备上单击汉堡图标,应显示导航栏的下拉菜单。

在我的原始文件中,我下载了 bootstrap.min.js 和 bootstrap.min.css 并链接了它们。我还在 bootstrap.min.js 之前链接了 jquery 库文件。我也尝试过使用 CDN 链接。但是还是没有什么好结果。当然,在调整浏览器大小时,导航栏会变得响应并变成汉堡图标。但是单击该图标实际上没有任何反应。

@import url('https://fonts.googleapis.com/css?family=Lato:400,700');
body {
background: #fff;
font-family: 'Lato', sans-serif;
font-style: normal;
font-weight: normal;
overflow-x: hidden;
}

html,
body {
width: 100%;
height: 100%;
}

.section {
padding-top: 100px;
padding-bottom: 100px;
position: relative;
background-color: #fff;
}

h1,
h2,
h3,
h4,
h5,
h6 {
font-style: normal;
font-weight: bold;
letter-spacing: 0px;
}

h1 {
color: #373737;
font-size: 45px;
line-height: normal;
}

h2 {
color: #454545;
font-size: 35px;
line-height: 52px;
margin-top: 0px;
}

h3 {
color: #585858;
font-size: 16px;
line-height: 32px;
letter-spacing: 6px;
text-transform: uppercase;
}

h4 {
color: #656565;
font-size: 20px;
}

p {
color: #878787;
font-size: 16px;
font-weight: normal;
line-height: 25px;
letter-spacing: 0.2px;
}


/*-------- Navigation section--------*/

.navbar-default {
border: none;
margin-bottom: 0;
background-color: #ffffff;
padding: 12px 0;
border-bottom: 1px solid #000;
}

.navbar-default .navbar-brand {
color: #444;
font-weight: normal;
font-size: 20px;
}

.navbar-default .navbar-nav li a {
font-size: 12px;
font-weight: bold;
color: #858585;
letter-spacing: 1px;
text-transform: uppercase;
-webkit-transition: all ease-in-out 0.4s;
transition: all ease-in-out 0.4s;
padding: 0 12px;
margin: 15px 8px;
}

.navbar-default .navbar-nav>li a:hover {
color: #000 !important;
}

.navbar-default .navbar-nav>li>a:hover,
.navbar-default .navbar-nav>li>a:focus {
color: #000;
}

.navbar-default .navbar-nav>.active>a,
.navbar-default .navbar-nav>.active>a:hover,
.navbar-default .navbar-nav>.active>a:focus {
color: #000;
}

.navbar-default .navbar-toggle {
border: none;
padding-top: 10px;
}

.navbar-default .navbar-toggle {
background-color: transparent;
}

.navbar-default .navbar-toggle .icon-bar {
background: #000000;
border-color: transparent;
}


/*=============Home section ===============*/

.home {
background-image: url(../images/bg.jpg);
background-size: cover;
background-attachment: fixed;
background-repeat: no-repeat;
background-position: center;
position: relative;
}

#home {
background-size: cover;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
height: 100vh;
position: relative;
}

.home .home-content p {
margin: auto;
font-size: 12px;
}

.home .home-content .site-name {
border: 4px solid #1a1a1a;
letter-spacing: 5px;
width: 240px;
padding: 12px;
border-bottom: 0;
}

.home .home-content h1 {
text-align: center;
}

.home .home-content h3 {
text-align: center;
}

.home .home-content {
text-align: center;
}

.home .home-content .border {
border: 4px solid #1a1a1a;
width: 230px;
padding: 28px 0px;
margin: 15px auto;
border-top: 0;
}

.section-btn {
background: #454545;
border: none;
border-radius: 0px;
color: #ffffff;
font-size: 13px;
font-weight: bold;
letter-spacing: 1.6px;
padding: 12px 32px 16px 32px;
margin-top: 42px;
-webkit-transition: all ease-in-out 0.4s;
transition: all ease-in-out 0.4s;
}

.section-btn:focus,
.section-btn:hover {
background: #000000;
color: #ffffff;
}


/*=============About section ===============*/

.about-social li {
display: inline-block;
}

.about-social li a {
color: #000;
display: inline-block;
height: 42px;
width: 42px;
font-size: 20px;
border-radius: 2%;
border: 1px solid #d4d4d4;
line-height: 40px;
transition: all 0.5s;
text-align: center;
}

.about-social li a:hover {
color: #fff;
border-color: #000;
background: #2d2d2d;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<!-- Navigation area -->
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-main">
<span class="sr-only">Toggle navigation</span>
<span class="icon icon-bar"></span>
<span class="icon icon-bar"></span>
<span class="icon icon-bar"></span>
</button>
<!-- Logo text -->
<a href="index.html" class="navbar-brand">Maureen.</a>
</div>
<!-- Navigation -->
<div class="collapse navbar-collapse" id="navbar-collapse-main">
<ul class="nav navbar-nav navbar-right">
<li><a class="active" href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#service">Service</a></li>
<li><a href="#resume">Resume</a></li>
<li><a href="#skills">Skills</a></li>
<li><a href="#portfolio">Portfolio</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div>
</div>
</nav>

<!-- Home section start -->
<section class="home" id="home">
<div class="container">
<div class="row">
<div class="col s12 m12 l6 center-align">
<div class="home-content">
<h1>HELLO THERE!</h1><br/>
<p>My name is Maureen</p>
<h3>I AM A UI/UX DEVELOPER</h3>
<div class="border"></div>
<a href="#" class="">Download Resume PDF</a>
</div>
</div>
</div>
</div>
</section>
<!-- About section -->
<section class="section" id="about">
<div class="container">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="mt-3">
<img src="images/profile-image.jpg" alt="" class="img-fluid mx-auto d-block img-thumbnail">
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="mt-3">
<h2>ABOUT ME</h2>
<h3 class="mt-4">HELLO! <span class="text-custom">I'M MAUREEN DOE.</span></h3>
<p class="text-muted mt-4">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tempor sem et nisi efficitur tempor.Phasellus pharetra dolor in enim pellentesque tincidunt vel non nisi. </p>
<p class="text-muted mt-2">Nullam posuere eu ante ut pharetra. Donec laoreet volutpat viverra. Vivamus ultrices, nibh eu porttitor luctus, odio lacus semper dolor, non scelerisque tellus augue a risus.</p>
<p class="text-muted mt-2">Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec quis ullamcorper tortor. Nulla quis bibendum ex. Etiam eget ullamcorper turpis, eu luctus nibh. </p><br/>
<div>
<ul class="about-social list-inline">
<li><a href="#"><i class="fab fa-facebook-f"></i></a></li>
<li><a href="#"><i class="fab fa-twitter"></i></a></li>
<li><a href="#"><i class="fab fa-instagram"></i></a></li>
<li><a href="#"><i class="fab fa-dribbble"></i></a></li>
<li><a href="#"><i class="fab fa-behance"></i></a></li>
<li><a href="#"><i class="fab fa-youtube"></i></a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- End of about section -->


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>

最佳答案

在执行此类操作时,务必确保您使用的是创作者推荐的库/框架。

当涉及到 Bootstrap 时,您应该尽量使所有 CDN 的版本控制尽可能相似。这是为 3.3.4 列出的 CDN

你有 3.3.4 css 和 3.3.6 js

@import url('https://fonts.googleapis.com/css?family=Lato:400,700');
body {
background: #fff;
font-family: 'Lato', sans-serif;
font-style: normal;
font-weight: normal;
overflow-x: hidden;
}

html,
body {
width: 100%;
height: 100%;
}

.section {
padding-top: 100px;
padding-bottom: 100px;
position: relative;
background-color: #fff;
}

h1,
h2,
h3,
h4,
h5,
h6 {
font-style: normal;
font-weight: bold;
letter-spacing: 0px;
}

h1 {
color: #373737;
font-size: 45px;
line-height: normal;
}

h2 {
color: #454545;
font-size: 35px;
line-height: 52px;
margin-top: 0px;
}

h3 {
color: #585858;
font-size: 16px;
line-height: 32px;
letter-spacing: 6px;
text-transform: uppercase;
}

h4 {
color: #656565;
font-size: 20px;
}

p {
color: #878787;
font-size: 16px;
font-weight: normal;
line-height: 25px;
letter-spacing: 0.2px;
}


/*-------- Navigation section--------*/

.navbar-default {
border: none;
margin-bottom: 0;
background-color: #ffffff;
padding: 12px 0;
border-bottom: 1px solid #000;
}

.navbar-default .navbar-brand {
color: #444;
font-weight: normal;
font-size: 20px;
}

.navbar-default .navbar-nav li a {
font-size: 12px;
font-weight: bold;
color: #858585;
letter-spacing: 1px;
text-transform: uppercase;
-webkit-transition: all ease-in-out 0.4s;
transition: all ease-in-out 0.4s;
padding: 0 12px;
margin: 15px 8px;
}

.navbar-default .navbar-nav>li a:hover {
color: #000 !important;
}

.navbar-default .navbar-nav>li>a:hover,
.navbar-default .navbar-nav>li>a:focus {
color: #000;
}

.navbar-default .navbar-nav>.active>a,
.navbar-default .navbar-nav>.active>a:hover,
.navbar-default .navbar-nav>.active>a:focus {
color: #000;
}

.navbar-default .navbar-toggle {
border: none;
padding-top: 10px;
}

.navbar-default .navbar-toggle {
background-color: transparent;
}

.navbar-default .navbar-toggle .icon-bar {
background: #000000;
border-color: transparent;
}


/*=============Home section ===============*/

.home {
background-image: url(../images/bg.jpg);
background-size: cover;
background-attachment: fixed;
background-repeat: no-repeat;
background-position: center;
position: relative;
}

#home {
background-size: cover;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
height: 100vh;
position: relative;
}

.home .home-content p {
margin: auto;
font-size: 12px;
}

.home .home-content .site-name {
border: 4px solid #1a1a1a;
letter-spacing: 5px;
width: 240px;
padding: 12px;
border-bottom: 0;
}

.home .home-content h1 {
text-align: center;
}

.home .home-content h3 {
text-align: center;
}

.home .home-content {
text-align: center;
}

.home .home-content .border {
border: 4px solid #1a1a1a;
width: 230px;
padding: 28px 0px;
margin: 15px auto;
border-top: 0;
}

.section-btn {
background: #454545;
border: none;
border-radius: 0px;
color: #ffffff;
font-size: 13px;
font-weight: bold;
letter-spacing: 1.6px;
padding: 12px 32px 16px 32px;
margin-top: 42px;
-webkit-transition: all ease-in-out 0.4s;
transition: all ease-in-out 0.4s;
}

.section-btn:focus,
.section-btn:hover {
background: #000000;
color: #ffffff;
}


/*=============About section ===============*/

.about-social li {
display: inline-block;
}

.about-social li a {
color: #000;
display: inline-block;
height: 42px;
width: 42px;
font-size: 20px;
border-radius: 2%;
border: 1px solid #d4d4d4;
line-height: 40px;
transition: all 0.5s;
text-align: center;
}

.about-social li a:hover {
color: #fff;
border-color: #000;
background: #2d2d2d;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- Navigation area -->
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-main" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- Logo text -->
<a href="index.html" class="navbar-brand">Maureen.</a>
</div>
<!-- Navigation -->
<div class="collapse navbar-collapse" id="navbar-collapse-main">
<ul class="nav navbar-nav navbar-right">
<li><a class="active" href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#service">Service</a></li>
<li><a href="#resume">Resume</a></li>
<li><a href="#skills">Skills</a></li>
<li><a href="#portfolio">Portfolio</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div>
</div>
</nav>

<!-- Home section start -->
<section class="home" id="home">
<div class="container">
<div class="row">
<div class="col s12 m12 l6 center-align">
<div class="home-content">
<h1>HELLO THERE!</h1><br/>
<p>My name is Maureen</p>
<h3>I AM A UI/UX DEVELOPER</h3>
<div class="border"></div>
<a href="#" class="">Download Resume PDF</a>
</div>
</div>
</div>
</div>
</section>
<!-- About section -->
<section class="section" id="about">
<div class="container">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="mt-3">
<img src="images/profile-image.jpg" alt="" class="img-fluid mx-auto d-block img-thumbnail">
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="mt-3">
<h2>ABOUT ME</h2>
<h3 class="mt-4">HELLO! <span class="text-custom">I'M MAUREEN DOE.</span></h3>
<p class="text-muted mt-4">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tempor sem et nisi efficitur tempor.Phasellus pharetra dolor in enim pellentesque tincidunt vel non nisi. </p>
<p class="text-muted mt-2">Nullam posuere eu ante ut pharetra. Donec laoreet volutpat viverra. Vivamus ultrices, nibh eu porttitor luctus, odio lacus semper dolor, non scelerisque tellus augue a risus.</p>
<p class="text-muted mt-2">Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec quis ullamcorper tortor. Nulla quis bibendum ex. Etiam eget ullamcorper turpis, eu luctus nibh. </p><br/>
<div>
<ul class="about-social list-inline">
<li><a href="#"><i class="fab fa-facebook-f"></i></a></li>
<li><a href="#"><i class="fab fa-twitter"></i></a></li>
<li><a href="#"><i class="fab fa-instagram"></i></a></li>
<li><a href="#"><i class="fab fa-dribbble"></i></a></li>
<li><a href="#"><i class="fab fa-behance"></i></a></li>
<li><a href="#"><i class="fab fa-youtube"></i></a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- End of about section -->


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>

关于html - 小屏幕上的 Bootstrap 导航栏没有下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54716257/

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