我知道這個問題之前已經被問過,但是,沒有一個答案似乎證明可行。Bootstrap下拉不工作(其他類似問題的解答不起作用!)
我已經制定了一個導航菜單中的下拉菜單,幾乎從示例複製。但是,當我點擊下拉菜單時,沒有任何反應。我已經包含了一個鏈接到JQuery,包括通過CDN的引導CSS/JS鏈接,並沒有任何工作。我也確保在引導之前放置JQuery。
我也嘗試刪除! - 可選主題引導鏈接(因爲一些人說過多個引導鏈接導致問題..)但沒有。
這可能是因爲我在localsever上運行它嗎?我懷疑...
讓我知道您的想法!謝謝!
這裏是我的代碼:
<!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">
<script
src="https://code.jquery.com/jquery-3.1.1.js"
integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA="
crossorigin="anonymous"></script>
<link rel="normalize.css">
<link href="https://fonts.googleapis.com/css?family=Courgette" rel="stylesheet">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3.css">
<!-- Latest compiled and minified CSS -->
<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://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="/style.css">
<?php wp_head(); ?>
</head>
<header>
<div class="container">
<div class="row>">
<div class="col-xl-12">
<img class="logo" src="<?php bloginfo('template_directory');?>/HSF.png">
<h1 class="title">TITLE</h1>
</div>
</div>
<div class="container">
<div class="row">
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="fwcnav" aria-expanded="false">
<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="#">Emerge</a>
</div>
<div class="collapse navbar-collapse" id="fwcnav">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home <span class="sr-only">(current) </span></a></li>
<li><a href="#">Recipes</a></li>
<li><a href="#">Little Ones</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Workout With Me <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Workouts</a></li>
<li><a href="#">Join A Challenge Group</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
</header>
編輯
好了,我發現我也有我的index.php的部分時,鏈接到我的樣式表。我擺脫了這一點,同時擺脫我的header.php中的樣式錶鏈接,並且代碼運行良好。我把我的鏈接放回到我的頭文件中的style.css文件中,然後再次搞砸了。所以,我猜在我的CSS中的東西使這個代碼搞砸了?
這裏是我的style.css:
/*
Theme Name: Title
Theme URI: Title
Description: X
Version: 1.0
Author: Author
Author URI: Website
*/
/* HEADER & NAVIGATION */
header {
background-color: rgb(20,20,20);
}
h1.title {
padding-top: 50px;
padding-left: 75px;
text-align: center;
font-size: 5em;
font-family: 'Courgette', cursive;
color: #f63a84;
}
/* BODY */
body {
background-color: rgb(20,20,20);
}
a {
color: #f63a84;
font-family: serif;
text-decoration: none;
}
a.button {
-webkit-appearance: button;
-moz-appearance: button;
appearance: button;
text-decoration: none;
height: 60px;
width: 400px;
font-size: 2em;
background-color: #f63a84;
color: white;
border: 2px solid black;
}
a.button2 {
-webkit-appearance: button;
-moz-appearance: button;
appearance: button;
text-decoration: none;
height: 60px;
width: 400px;
font-size: 1.5em;
background-color: #f63a84;
color: white;
border: 2px solid black;
}
h2 {
font-size: 28px;
color: #f63a84;
font-style: bold;
}
img.logo {
float: right;
width: 175px;
height: 175px;
padding-top: 0px;
}
/* NAVIGATION */
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
text-align: center;
}
li {
display: inline-block;
float: left;
}
a {
display: block;
padding: 8px;
}
/* CONTENT */
article {
max-width: 950px;
padding: 20px 0 100px 40px;
margin-left: 40px;
}
article.home {
padding: 20px 0 100px 0;
margin-left: 0px;
}
article.other {
padding: 20px 0 100px 0;
margin-left: 0px;
}
article.blog-article {
max-width: 950px;
padding: 20px 0 50px 40px;
margin-left: 40px;
margin-top: 0px;
}
p {
font-size: 18px;
font-family: serif;
line-height: 40px;
color: rgb(248,248,248);
padding: 0 0 0 45px;
}
button {
height: 60px;
width: 400px;
font-size: 2em;
background-color: #f63a84;;
color: white;
border: 2px solid black;
}
.button:hover {
background-color: white;
color: #f63a84;
}
/* FOOTER */
footer {
position: fixed;
height: 100px;
bottom: 0;
width: 100%;
}
/* MEDIA RESPONSIVENESS */
@media (max-width: @screen-xl) {
h1.title {font-size: 1em;}
}
瀏覽器控制檯的任何線索? –
不確定你的意思?檢查元素?查看源代碼? – tombedorchestra
運動 加入頻道組下拉菜單?它適用於我的地方 – Calvin