gpt4 book ai didi

jquery - Bootstrap 导航栏 CSS 只能部分工作

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

我遇到了一个奇怪的问题,Boostrap 3.3.6 CSS 只能部分工作。虽然我相信该站点已正确构建(正确的类在正确的位置等),但看起来某些 CSS 根本不存在。

这是我的导航栏的样子: A not-very-useful navbar

这是我页面的代码。 CSS 和 JS 的链接确实有效,我也没有对两者进行任何更改。这是从 Bootstrap 站点直接下载的。

如果我用指向 MaxCDN 的 CSS 文件的链接替换指向我的服务器端 CSS 的链接,问题仍然存在。

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/style/css/bootstrap.css">
<link rel="stylesheet" href="/style/css/bootstrap-theme.css">

<title>Test Page</title>
</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Test Page</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="navbar navbar-nav navbar-left">
<li><a href="#">Home</a>
</li>
<li><a href="">Link</a>
</li>
<li class="dropdown">
<a class="dropdown-toggle nolink-pointer" data-toggle="dropdown">Dropdown 1 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="">Link</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle nolink-pointer" data-toggle="dropdown">Dropdown 2 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="">Link</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle nolink-pointer" data-toggle="dropdown">Dropdown 3 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="">Link</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle nolink-pointer" data-toggle="dropdown">Dropdown 4 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="">Link</a>
</li>
</ul>
</li>
<li><a href="">Link</a>
</li>
<li><a href="">Link</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<p>Test</p>
</div>
<footer class="footer">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script type="text/javascript" src="/style/js/bootstrap.min.js"></script>
</footer>
</body>

</html>

最佳答案

你有 <ul class="navbar navbar-nav navbar-left"> ,应该是nav , 不是 navbarul里面.参见 Navbar . <ul class="nav navbar-nav navbar-left">

*请注意,由于您有太多链接,您将看到它们在 992 像素以下溢出。

旁注:考虑将脚本放在结束正文标记之前,而不是在 footer 内标签。

 <footer class="footer">
</footer>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script type="text/javascript" src="/style/js/bootstrap.min.js"></script>

</body>

请参阅 FullPage 上的工作示例。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Test Page</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-left">
<li><a href="#">Home</a>
</li>
<li><a href="">Link</a>
</li>
<li class="dropdown">
<a class="dropdown-toggle nolink-pointer" data-toggle="dropdown">Dropdown 1 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="">Link</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle nolink-pointer" data-toggle="dropdown">Dropdown 2 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="">Link</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle nolink-pointer" data-toggle="dropdown">Dropdown 3 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="">Link</a>
</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle nolink-pointer" data-toggle="dropdown">Dropdown 4 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="">Link</a>
</li>
</ul>
</li>
<li><a href="">Link</a>
</li>
<li><a href="">Link</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<p>Test</p>
</div>

关于jquery - Bootstrap 导航栏 CSS 只能部分工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35383378/

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