3 回答

TA貢獻1878條經(jīng)驗 獲得超4個贊
首先使用而不是嘗試在您的部分中使用此元標記<head>
<header>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
然后,導航欄將折疊所有小于768px的屏幕尺寸,作為引導的默認行為。因此,要將其擴展到某個屏幕斷點,您可以將此類組合添加到主導航元素中。navbar-expand-*
希望它對你有用。

TA貢獻1812條經(jīng)驗 獲得超5個贊
在代碼中應考慮許多事項。
您應該將資源放在
<標題>
而不是<標題>
。這兩者之間有一個主要區(qū)別,一個包含機器可讀的信息,而另一個代表介紹性內(nèi)容。您需要在引導.js之前加載
jquery.min
.js
,因為引導程序需要使用 jQuery。您還需要添加
<meta名稱=“視口”內(nèi)容=“寬度=設備寬度,初始比例=1”>
,以便能夠控制所有屏幕尺寸的視口。<head>
通過遵循這兩個注釋,您的代碼應該按預期工作。
<html>
<head>
<title>title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<div class="wrap">
<!-- 以下為頁眉內(nèi)容 -->
<nav id="w1" class="navbar-default navbar-fixed-top navbar">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#w1-collapse"><span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span></button>
<a class="navbar-brand" href="/index.php">Logo</a></div>
<div id="w1-collapse" class="collapse navbar-collapse">
<ul id="w2" class="navbar-nav navbar-right nav">
<li><a href="/index.php?r=site%2Findex">主頁</a></li>
<li><a href="https://docs.mathcrowd.cn" target="_blank">文檔</a></li>
<li><a href="/index.php?r=worksheet%2Ffilter">卷庫</a></li>
<li class="help-link"><a href="javascript:void(0);"><span class="glyphicon glyphicon-question-sign"></span></a></li>
<li><a href="/index.php?r=cart%2Fview"><span class="glyphicon glyphicon-shopping-cart"></span></a>
</li>
</ul>
</div>
</div>
</nav>
<!-- 結(jié)束 -->
</div>
</body>
</html>

TA貢獻1773條經(jīng)驗 獲得超3個贊
使用 標記。并在頁面末尾附近,在 標記結(jié)束之前包含 js 文件。為了節(jié)省將來的時間,請訪問引導官方文檔。https://getbootstrap.com/docs/4.5/getting-started/introduction/<head>
</body>
它是最好和寫得很好的文檔之一。
添加回答
舉報