当窗口尺寸减小时,桌子堆放在侧边栏下方

时间:2014-04-07 10:52:22

标签: html css twitter-bootstrap

使用由两列组成的bootstrap创建网站。第一列是侧栏,第二列是表格。

当屏幕尺寸不缩小时,页面看起来很好。

但是当窗口缩小时,桌子会堆叠在侧边栏下面。

我想把桌子留在旁边吧。

http://www.bootply.com/128015

代码如下。

<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <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="#"><h1>&nbsp;LDSLDSLDLSDL</h1></a>

        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

            <ul class="nav navbar-nav navbar-right">
                <li><a href="#"><img src="" height="75px" width="337.5px"></a></li>

            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="col-md-2">
            <div class=" bs-docs-sidebar">
                <ul class="nav nav-list bs-docs-sidenav ">
                    <li><a href="#"><i class="icon-chevron-right"></i>Book an appointment </a></li><hr>
                    <li><a href="#"><i class="icon-chevron-right"></i>Search</a></li><hr>
                    <li><a href="#"><i class="icon-chevron-right"></i>Visits</a></li><hr>
                    <li><a href="#"><i class="icon-chevron-right"></i> Share Info</a></li><hr>
                    <li><a href="#"><i class="icon-chevron-right"></i> Association</a></li><hr>
                    <li><a href="#"><i class="icon-chevron-right"></i>Upload Document</a></li><hr>

                </ul>
            </div>
        </div>
        <div class="col-md-10">
            <table class="table">
                <tbody><tr class="success">
                    <td>1</td>
                    <td>TB - Monthly</td>
                    <td>01/04/2012</td>
                    <td>Approved</td>
                </tr>
            </tbody></table>
       </div>
    </div>
 </div>

1 个答案:

答案 0 :(得分:0)

在较小的分辨率上,这些元素不再具有它们的样式(因为某些引导媒体查询条件),所以你可以添加它们:

.col-md-2 { 
  width: 16.67%;
}
.col-md-10 { 
  width: 83.33%;
}
.col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 { 
  float: left;
}

如果你将它们添加到你自己的样式上并使它们更具体(通过在每个col-class之前添加“.container-fluid”),它们将被覆盖,并且表格将不再被堆叠。

.container-fluid .col-md-2 { 
  width: 16.67%;
}
.container-fluid .col-md-10 { 
  width: 83.33%;
}
.container-fluid .col-md-1, .container-fluid .col-md-2, .container-fluid .col-md-3, .container-fluid .col-md-4, .container-fluid .col-md-5, .container-fluid .col-md-6, .container-fluid .col-md-7, .container-fluid .col-md-8, .container-fluid .col-md-9, .container-fluid .col-md-10, .container-fluid .col-md-11, .container-fluid .col-md-12 { 
  float: left;
}

或者只是在每个样式属性后添加“!important”。

 .col-md-2 { 
      width: 16.67% !important;
   }
    .col-md-10 { 
      width: 83.33% !important;
    }
    .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 { 
      float: left !important;
    }