下拉菜单不工作引导程序

时间:2016-03-14 14:22:58

标签: html css twitter-bootstrap

这很简单。如果引用一切流行的,我和我正在观看的视频完全相同,所以我不确定发生了什么。如果我点击我的下拉菜单,它不会下拉会发生什么。

这是我的代码:

<!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">
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <div class="container">
      <div class="row">
        <div class="cox-md-12">
          <ul class="nav nav-pills">
            <li class="active"><a href="#">Index</a></li>
            <li><a href="#">Push Pull</a></li>
            <li><a href="#">Nesting</a></li>
            <li><a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown<span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="#">Item 1</a></li>
                <li><a href="#">Item 2</a></li>
              </ul>
            </li>
          </ul>
        </div>
      </div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="js/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>

我的CSS代码:

html{
    position: relative;
    width: 100%;
    min-height: 100%;
}
body{
    font-family: "Roboto";
    margin-bottom: 60px;
}
a{
    color:#00A0F0;
}
.spacer{
    height:70px;
    width: 100%;
}
.spacer-1{width:100%;height:10px;}.spacer-2{width:100%;height:20px;}.spacer-3{width:100%;height:30px;}.spacer-4{width:100%;height:40px;}
.spacer-5{width:100%;height:50px;}.spacer-6{width:100%;height:60px;}.spacer-7{width:100%;height:70px;}.spacer-8{width:100%;height:80px;}
.spacer-9{width:100%;height:90px;}.spacer-10{width:100%;height:100px;}.spacer-11{width:100%;height:110px;}.spacer-12{width:100%;height:120px;}

.locationTitle{
    text-align: left;
    font-weight: 700;
    font-size: 2em;
    color:#06a;
    margin-bottom: 24px;
    margin-left: 24px;
    margin-top: 24px;
}
.subTitle{
    text-align: center;
}
.subHead{
    line-height: 1em;
    font-size: .6em;
}
.navbar{
    border: 0px solid #white;
    border-bottom: 2px solid #CCC;
    box-shadow: 0 0 2px 1px grey;
    height: 100px;
    background-color: white;
}
.navbar>.container-fluid{
    height: 100px;
    padding: 0;
}
.navbar>.container-fluid>*{
    height: 100px;
}
.navbar>.container-fluid img{
    height: 100px;
}
.branding *{
    display: block;
    text-align: center;
    padding: 2px 6px 6px;
    color: #06a
}
.navRows{
    height: 100%;
    padding: 0px;
}
.navRows>div{
    font-size: 1.4em;
    line-height: 40px;
    padding: 5px 0;
    text-align: center;
}
.navRows[data-expand="false"]>div{
    height: 50%;
}
.navRows[data-expand="true"]>div{
    background-color: #06a;
    text-align: left;
    z-index: 9999;
}
.contactspacer {
  margin-top: 45px;
}
.navIcon{
    padding: 10px;
    border-radius: 50%;
    color:white;
    background-color: #06a;
}
.navTopRow{
    background-color: #06a;
    color: white
    margin-top: 50px;
}
.navTopRow a{
    margin-top: 25px;
    color: white;
    font-size: 16px;
}
.navbar > li > a:hover{
    text-shadow: 0 1px 3px #CDF;
}
.navbar li:not(.navSep):hover{
    margin: 0 0 -2px 0;
    border-bottom: 2px solid white;
}

.navSep{
    width:2px;
    height: 40px;
    margin: 5px 2px 5px 2px;
    background-color: #A9AFDD;
}

.imgCon{
    max-height: 100%;
    max-width:100%;
}
.imgCon img{
    width: auto;
    height: auto;
    max-width:100%;
    max-height: 100%;
}

.page{
    width: 100%;
    height: 100%;
    padding-bottom:50px;
}

@media (max-width:768px){
    div[aria-expanded="true"] .navSep{
        display: none;
    }
}

.mainTitle{
    font-size: 1.5em;
    font-weight: 700;
    background-color: white;
}

.extraInfo{
    background-color: #333;
    color:white;
    box-shadow: 1px 1px 2px 1px grey;
    font-size: 1.2em;
}

.footer{
    background-color: #06a;
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100px;
    text-align: right;
}
.footer a{
    text-align: center;
    border-top: 1px solid grey;
    height: 100%;
    color: white;
}
.footer p{
    text-align: center;
    height: 100%;
    color: white;
}
@media (min-width : 1200px) {
    .col-xl-0{display:none;}
}
@media (max-width : 1200px){
    .col-lg-0{display:none;}
}
@media (max-width : 992px){
    .col-md-0{display:none;}
}
@media (max-width : 768px){
    .col-sm-0{display:none;}
}
@media (max-width : 480px){
    .col-xs-0{display:none;}
}




@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400;
  src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/CWB0XYA8bzo0kSThX0UTuA.woff2) format('woff2');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 700;
  src: local('Roboto Bold'), local('Roboto-Bold'), url(https://fonts.gstatic.com/s/roboto/v15/d-6IYplOFocCacKzxwXSOFtXRa8TVwTICgirnJhmVJw.woff2) format('woff2');
}

2 个答案:

答案 0 :(得分:0)

如果您正确粘贴了CDN,它就能正常工作

作为

 <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

然后它将完美地工作如下,

&#13;
&#13;
<html lang="en">
  <head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  </head>
  <body>
    <div class="container">
      <div class="row">
        <div class="cox-md-12">
          <ul class="nav nav-pills">
            <li class="active"><a href="#">Index</a></li>
            <li><a href="#">Push Pull</a></li>
            <li><a href="#">Nesting</a></li>
            <li><a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown<span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="#">Item 1</a></li>
                <li><a href="#">Item 2</a></li>
              </ul>
            </li>
          </ul>
        </div>
      </div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="js/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

检查您是否使用最新版本的bootsrap

然后检查https://jsfiddle.net/qy59y2fs/

<div class="dropdown">