2013-06-19 69 views
1

我正在以與頂部欄相同的方式摺疊側欄(摺疊+按鈕)。在調整大小或在移動設備上時摺疊側邊欄

到目前爲止,我在屏幕大小調整時出現了按鈕。但是,它不會在內容上方擴展邊欄。我點擊按鈕,沒有發生任何事情。

這裏是我的源文件:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="utf-8"> 
<title>Bootstrap, from Twitter</title> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<meta name="description" content=""> 
<meta name="author" content=""> 

<!-- Le styles --> 
<link href="assets/css/bootstrap.css" rel="stylesheet"> 
<style type="text/css"> 
body { 
    padding-top: 60px; 
    padding-bottom: 40px; 
} 

.sidebar-nav { 
    padding: 9px 0; 
} 

@media (max-width : 980px) { /* Enable use of floated navbar text */ 
    .navbar-text.pull-right { 
     float: none; 
     padding-left: 5px; 
     padding-right: 5px; 
    } 
} 
</style> 
<link href="assets/css/bootstrap-responsive.css" rel="stylesheet"> 

<!-- HTML5 shim, for IE6-8 support of HTML5 elements --> 
<!--[if lt IE 9]> 
     <script src="assets/js/html5shiv.js"></script> 
    <![endif]--> 

<!-- Fav and touch icons --> 
<link rel="apple-touch-icon-precomposed" sizes="144x144" 
    href="assets/ico/apple-touch-icon-144-precomposed.png"> 
<link rel="apple-touch-icon-precomposed" sizes="114x114" 
    href="assets/ico/apple-touch-icon-114-precomposed.png"> 
<link rel="apple-touch-icon-precomposed" sizes="72x72" 
    href="assets/ico/apple-touch-icon-72-precomposed.png"> 
<link rel="apple-touch-icon-precomposed" 
    href="assets/ico/apple-touch-icon-57-precomposed.png"> 
<link rel="shortcut icon" href="assets/ico/favicon.png"> 
</head> 

<body> 

    <div class="navbar navbar-inverse navbar-fixed-top"> 
     <div class="navbar-inner"> 
      <div class="container-fluid">No menu here...</div> 
     </div> 
    </div> 

    <div class="container-fluid"> 
     <div class="row-fluid"> 
      <div class="span3"> 
       <button type="button" class="btn btn-navbar" 
data-toggle="collapse" data-target=".nav-collapse"> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
       </button> 

       <div class="nav-collapse collapse"> 
        <div class="sidebar-nav"> 
         <ul class="nav nav-list"> 
          <li class="nav-header">Sidebar</li> 
          <li class="active"><a href="#">Link</a></li> 
          <li><a href="#">Link</a></li> 
          <li><a href="#">Link</a></li> 
          <li><a href="#">Link</a></li> 
          <li class="nav-header">Sidebar</li> 
          <li><a href="#">Link</a></li> 
          <li><a href="#">Link</a></li> 
          <li><a href="#">Link</a></li> 
          <li><a href="#">Link</a></li> 
          <li><a href="#">Link</a></li> 
          <li><a href="#">Link</a></li> 
          <li class="nav-header">Sidebar</li> 
          <li><a href="#">Link</a></li> 
          <li><a href="#">Link</a></li> 
          <li><a href="#">Link</a></li> 
         </ul> 
        </div> 
        <!--nav collapse --> 
       </div> 
       <!--/.span3 --> 
      </div> 
      <!--/span--> 
      <div class="span9"> 
       <h1>Content in here...</h1> 
      </div> 
     </div> 
     <!--/row--> 

     <hr> 

     <footer> 
      <p>&copy; Company 2013</p> 
     </footer> 

    </div> 
    <!--/.fluid-container--> 

    <!-- Le javascript 
    ================================================== --> 
    <!-- Placed at the end of the document so the pages load faster --> 
    <script src="assets/js/jquery.js"></script> 
    <script src="assets/js/bootstrap-transition.js"></script> 
    <script src="assets/js/bootstrap-alert.js"></script> 
    <script src="assets/js/bootstrap-modal.js"></script> 
    <script src="assets/js/bootstrap-dropdown.js"></script> 
    <script src="assets/js/bootstrap-scrollspy.js"></script> 
    <script src="assets/js/bootstrap-tab.js"></script> 
    <script src="assets/js/bootstrap-tooltip.js"></script> 
    <script src="assets/js/bootstrap-popover.js"></script> 
    <script src="assets/js/bootstrap-button.js"></script> 
    <script src="assets/js/bootstrap-collapse.js"></script> 
    <script src="assets/js/bootstrap-carousel.js"></script> 
    <script src="assets/js/bootstrap-typeahead.js"></script> 

</body> 
</html> 

這裏是指示做引導CSS文件的更改我的補丁文件。我主要向.btn-navbar添加了與.navbar .btn-navbar相同的樣式,在這些樣式之前添加了.btn-navbar。

diff --git a/assets/css/bootstrap-responsive.css b/assets/css/bootstrap-responsive.css 
--- a/assets/css/bootstrap-responsive.css 
+++ b/assets/css/bootstrap-responsive.css 
@@ -1092,7 +1092,7 @@ 
    height: 0; 
    overflow: hidden; 
    } 
- .navbar .btn-navbar { 
+ .btn-navbar, .navbar .btn-navbar { 
    display: block; 
    } 
    .navbar-static .navbar-inner { 



diff --git a/assets/css/bootstrap.css b/assets/css/bootstrap.css 
--- a/assets/css/bootstrap.css 
+++ b/assets/css/bootstrap.css 
@@ -4631,7 +4631,7 @@ 
      box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125); 
} 

-.navbar .btn-navbar { 
+.btn-navbar, .navbar .btn-navbar { 
    display: none; 
    float: right; 
    padding: 7px 10px; 
@@ -4656,6 +4656,12 @@ 
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075); 
} 

+.btn-navbar:hover, 
+.btn-navbar:focus, 
+.btn-navbar:active, 
+.btn-navbar.active, 
+.btn-navbar.disabled, 
+.btn-navbar[disabled], 
.navbar .btn-navbar:hover, 
.navbar .btn-navbar:focus, 
.navbar .btn-navbar:active, 
@@ -4667,12 +4673,14 @@ 
    *background-color: #d9d9d9; 
} 

+.btn-navbar:active, 
+.btn-navbar.active, 
.navbar .btn-navbar:active, 
.navbar .btn-navbar.active { 
    background-color: #cccccc \9; 
} 

-.navbar .btn-navbar .icon-bar { 
+.btn-navbar .icon-bar, .navbar .btn-navbar .icon-bar { 
    display: block; 
    width: 18px; 
    height: 2px; 

目標是將這些移出到我的自定義CSS中,一旦我有它的工作。

對於.btn來說,jQuery文件看起來挺簡單的,沒有看到任何需要更改的文件。

回答

相關問題