所以我正在使用模板「Butterfly」的引導程序網站上工作到目前爲止,除了移動設備調整大小的導航欄外,一切工作正常。由於某些原因,移動設備上的下拉菜單無法打開。我正在使用一個PHP include標籤來輕鬆地在網站的每個頁面上包含相同的導航欄,並允許輕鬆更新它。Bootstrap navbar下拉菜單不起作用
<?php include_once("template/menu.html"); ?>
導航欄代碼:
<!--Mobile version of header-->
<ul class="toggle">
<li><a href="../index.php">Home</a></li>
<li><span style="cursor:pointer">
<div class="dropdown">
<a class="dropdown-toggle disabled" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Properties
<span class="caret"></span>
</a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a href="#">Link 3<span class="label label-success label-as-badge">0 New</span></a></li>
<li><a href="#">Link 2<span class="label label-success label-as-badge">3 New</span></a></li>
<li><a href="#">Link 3<span class="label label-success label-as-badge">Nothing here</span></a></li>
</ul>
</div></span>
</li>
<li><a href="#work_outer">Links</a></li>
<li><a href="#Portfolio">About</a></li>
<li><a href="#client_outer">Apply</a></li>
</ul>
這裏是導航欄的CSS:
.nav-right{
float:right;
}
.nav ul{
list-style:none;
padding:0px;
}
.nav ul.toggle{
display:none;
visibility:hidden;
height:0px;
overflow:hidden;
margin-bottom: 0;
}
.nav ul li{
display:inline-block;
margin:0 23px;
}
.nav ul li:first-child{
/*margin:0px;*/
}
.nav ul li:last-child{
margin:0 0 0 23px;
}
.nav ul li a{
display:block;
font-size:14px;
color:#222222;
font-family:'Dosis';
text-decoration:none;
text-transform:uppercase;
font-weight: 600;
transition:all 0.2s ease-in-out;
-moz-transition:all 0.2s ease-in-out;
-webkit-transition:all 0.2s ease-in-out;
}
.nav ul li a:hover{
color:#49b5e7;
}
下面是導航欄的一些更多的CSS。最重要的是從bootstrap.css默認的,但我不知道:
.dropdown {
position: relative;
}
.dropdown-toggle:focus {
outline: 0;
}
.dropdown-menu {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
display: none;
float: left;
min-width: 160px;
padding: 5px 0;
margin: 2px 0 0;
list-style: none;
font-size: 14px;
background-color: #ffffff;
border: 1px solid #cccccc;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 4px;
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
background-clip: padding-box;
}
.dropdown-menu.pull-right {
right: 0;
left: auto;
}
.dropdown-menu .divider {
height: 1px;
margin: 9px 0;
overflow: hidden;
background-color: #e5e5e5;
}
.dropdown-menu > li > a {
display: block;
padding: 3px 20px;
clear: both;
font-weight: normal;
line-height: 1.428571429;
color: #333333;
white-space: nowrap;
}
.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus {
text-decoration: none;
color: #262626;
background-color: #f5f5f5;
}
.dropdown-menu > .active > a,
.dropdown-menu > .active > a:hover,
.dropdown-menu > .active > a:focus {
color: #ffffff;
text-decoration: none;
outline: 0;
background-color: #428bca;
}
.dropdown-menu > .disabled > a,
.dropdown-menu > .disabled > a:hover,
.dropdown-menu > .disabled > a:focus {
color: #999999;
}
.dropdown-menu > .disabled > a:hover,
.dropdown-menu > .disabled > a:focus {
text-decoration: none;
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
cursor: not-allowed;
}
.open > .dropdown-menu {
display: block;
}
.open > a {
outline: 0;
}
.dropdown-header {
display: block;
padding: 3px 20px;
font-size: 12px;
line-height: 1.428571429;
color: #999999;
}
.dropdown-backdrop {
position: fixed;
left: 0;
right: 0;
bottom: 0;
top: 0;
z-index: 990;
}
感謝您的閱讀,任何幫助深表感謝。如果您需要更多信息,只需詢問我會在代碼中找到它併發布。再次感謝大家!
你應該張貼問題的工作示例。您發佈的代碼不會產生與您在問題中關聯的主題相似的內容。有可能是加載移動導航功能所需的JS所帶來的問題。 – vanburen
你應該在'body'標籤的末尾加載'jquery'。 –