Bootstrap菜单无法正常工作

时间:2016-03-16 20:38:19

标签: jquery html css twitter-bootstrap

我正在构建一个Bootstrap网站,我的移动下拉菜单存在问题。它会下降,但它与所有东西融为一体。我可以点击链接,但看起来很可怕。

以下是它的样子:example for notifications

这是我的代码:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="index,follow">
        <meta name="keywords" content=",internet,ISP,phone,telephone,tv,televison,internet,services,dsl,fttn,cable,wireless,lets,get,connected,">
        <title>{{var pageTitle}}</title>
        <link rel="icon" type="image/png" href="#">
        <link rel="icon" type="image/x-icon" href="{{var protoHost}}favicon.ico">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
        <link rel="stylesheet" href="{{var protoHost}}css/main.css">
        <link rel="stylesheet" href="{{var protoHost}}css/print.css">
        {{var extraHeaders}}
    </head>
    <body>
        <div class="page">
            <nav class="navbar navbar-default navbar-fixed-top">
                <div class="container-fluid">
                    <!-- <div class="navbar-header">
                      <a class="navbar-brand imgCon" href="{{var protoHost}}">
                        <img src="{{var protoHost}}img/TrueInternet.png">
                      </a>
                    </div>
                    <div class="navRows">
                        <div class="navTopRow">
                            <span><i class="fa fa-comment navIcon"></i> Top Content</span>
                        </div>
                        <div class="navBottomRow">
                            <span><a href="#"><i class="fa fa-users navIcon"></i> Bottom Content</a></span>
                        </div>
                    </div> -->
                    <div class="col-xs-10 col-sm-3 branding">
                        <a class="imgCon" href="{{var protoHost}}">
                            <img alt="TrueSpeed Internet Services" src="{{var protoHost}}img/TrueInternet.png">
                        </a>
                    </div>
                    <div class="visible-xs-block visible-sm-block visible-md-block">
                        <button id="btnToggleNavMenu" type="button" name="button"><i class="fa fa-bars"></i></button>
                    </div>
                    <div class="col-xs-12 col-sm-9 navRows" data-expand="false">
                        <div class="navTopRow">
                            <span class="col-xs-8 col-md-2"><i class="fa fa-cloud-download navIcon fa-lg"></i><a href="/internet" color="white">Internet</a></span>
                            <span class="col-xs-8 col-md-2"><i class="fa fa-phone navIcon fa-lg"></i><a href="/phone">Phone</a></span>
                            <span class="col-xs-8 col-md-3"><i class="fa fa-television navIcon fa-lg"></i><a href="/televison">Television</a></span>
                            <span class="col-xs-12 col-md-2"><a href="/contact"><i class="fa fa-comment navIcon fa-lg"></i>Contact Us</a></span>
                            <span class="col-xs-12 col-md-3"><a href="#"><i class="fa fa-users navIcon"></i>Referral Program</a></span>
                        </div>
                    </div>
                </div>
            </nav>

            <div class="container">
                <div class="spacer-11 printHide"></div>
                {{var content}}
            </div>
            <footer class="footer">
                <div class="container">
                    <div class="row">
                        <a class="col-xs-2 col-md-2"href="{{var protoHost}}PrivacyPolicy">Privacy Policy</a>
                        <a class="col-xs-2 col-md-2"href="{{var protoHost}}TermsOfService">Terms Of Service</a>
                        <a class="col-xs-2 col-md-2"href="{{var protoHost}}AcceptableUsePolicy">Acceptable Use Policy</a>
                        <a class="col-xs-2 col-md-2"href="{{var protoHost}}WarrentyAndReturnsPolicy">Warranty &amp; Returns Policy</a>
                        <a class="col-xs-2 col-md-2" href="{{var protoHost}}ThridPartyCopyrightNotices">Third Party Copyright Notices</a>
                        <a class="col-xs-2 col-md-2"href="{{var protoHost}}TermsOfServicePhone">Terms Of Service For Phone</a>
                    </div>
                    <p>&copy; 2016 Internet Services - All Rights Reserved</p>
                </div>
            </footer>
        </div>
        <script src="js/jquery.min.js"></script>
        <script src="js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
        <script src="{{var protoHost}}js/navCode.js"></script>
        {{var extraScripts}}

    </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');
}

1 个答案:

答案 0 :(得分:2)

这是你要做的事情

http://getbootstrap.com/components/#navbar

查看他们提供的示例并遵循它,您没有使用正确的引导类来为您提供您期望的样式。

<ul class="nav navbar-nav">
    <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
    <li><a href="#">Link</a></li>
    <li class="dropdown">
      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
      <ul class="dropdown-menu">
        <li><a href="#">Action</a></li>
        <li><a href="#">Another action</a></li>
        <li><a href="#">Something else here</a></li>
        <li role="separator" class="divider"></li>
        <li><a href="#">Separated link</a></li>
        <li role="separator" class="divider"></li>
        <li><a href="#">One more separated link</a></li>
      </ul>
    </li>
  </ul>

确保您使用提供的nav navbar-nav类。它们为您的内容提供所需的属性。