使用bootstrap 3列不排队

时间:2014-01-29 23:28:39

标签: javascript css twitter-bootstrap twitter-bootstrap-3

我正在使用twitter bootstrap版本3,由于某种原因,列的宽度不合适。

看看这张照片:http://i.imgur.com/LhgqL12.png

右列不与旋转木马的末尾对齐,我无法弄清楚原因!

这是页面的html:

    <!-- navbar -->
    <div class="col-md-12">
        <div class="container">
            <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
                <ul class="nav navbar-nav">
                    <li><a href="/home/" class="homelink"><span class="glyphicon glyphicon-home"></span></a></li>
                    <li><a href="/donate/">Donate</a></li>
                    <li><a href="/sales/">Sales</a></li>
                    <li><a href="/contact-us/">Submit Tip</a></li>
                    <li><a href="/crowdfunding/">Gaming Wiki</a></li>
                    <li><a href="/about-us/">About Us</a></li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Community <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li><a href="/forum/">Forum</a></li>
                            <li><a href="/irc/">IRC Chat</a></li>
                            <li><a href="http://www.twitter.com/gamingonlinux">Twitter</a></li>
                            <li><a href="http://www.twitter.com/linuxgamesales">Sales Twitter</a></li>
                            <li><a href="https://plus.google.com/104852318604553771493">Google+</a></li>
                            <li><a href="/links/">Links</a></li>
                        </ul>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"></span> liamdawe <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                                                    <li><a href="/profiles/1">View Profile</a></li> 
                                <li><a href="/usercp.php">User CP</a></li>
                                <li><a href="/private-messages/">Private Messages</a></li>
                                <li><a href="/admin.php">Admin CP <span class="badge badge-important">3</span></a></li>
                                <li><a href="/index.php?act=Logout">Logout</a></li>
                        </ul>
                    </li>
                </ul>
                <form method="get" action="/index.php?module=search" class="navbar-form navbar-right" role="search">
                    <input type="hidden" name="module" value="search">
                    <input type="text" class="form-control" name="q" placeholder="Search Articles">
                    <input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"/>
                </form>
            </nav>
        </div>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <!-- logo -->
                <a href="http://www.gamingonlinux.com"><img src="/templates/default/images/logo.png" height="120" width="600" alt="logo" class="logo-center" /></a>
            </div>
        </div>
        <div class="row">
            <!-- image carousel -->
            <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
              <!-- Indicators -->
              <ol class="carousel-indicators">
                <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
                <li data-target="#carousel-example-generic" data-slide-to="1"></li>
                <li data-target="#carousel-example-generic" data-slide-to="2"></li>
              </ol>

              <!-- Wrapper for slides -->
              <div class="carousel-inner">
               <div class="item active">
      <a href="http://www.gamingonlinux.com/forum/topic/327"><img src="/uploads/carousel/1294630814id6gol.jpg" class="logo-center" alt="" /></a>
      <div class="carousel-caption">
        <h3><a href="http://www.gamingonlinux.com/forum/topic/327" class="white-link">Join our Minecraft server!</a></h3>
      </div>
    </div><div class="item">
          <a href="http://www.gamingonlinux.com/articles/natural-selection-2-fpsrts-will-release-on-linux-august-30th.2270"><img src="/uploads/carousel/882399500id7gol.jpg" class="logo-center" alt="" /></a>
          <div class="carousel-caption">
        <h3><a href="http://www.gamingonlinux.com/articles/natural-selection-2-fpsrts-will-release-on-linux-august-30th.2270" class="white-link">Natural Selection 2 Out on the 30th for Linux!</a></h3>
          </div>
        </div>
              </div>

              <!-- Controls -->
              <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
                <span class="glyphicon glyphicon-chevron-left"></span>
              </a>
              <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
                <span class="glyphicon glyphicon-chevron-right"></span>
              </a>
            </div><!-- /.carousel -->
        </div>

    <!-- main content -->
    <div class="row">
            <!-- Articles -->
            <div class="col-md-9">

                <!-- notification -->
                <div class="row">
                    <div class="alert alert-warning text-center">
                        <a href="/admin.php">You have <span class="badge badge-important">3</span> admin items needing review!</a> 
                    </div>
                </div>

    <!-- new sales -->
    <div class="row">
            <div class="alert alert-success text-center">
                <strong>Latest Games On Sale:</strong> <a href="/sales/#86"><span class="label label-info">Steam</span> Sparkle 2 Evo</a>, <a href="/sales/#85"><span class="label label-info">Steam</span> Shadow Warrior Classic Redux</a>, <a href="/sales/#84"><span class="label label-info">Steam</span> Redshirt</a>, <a href="/sales/#83"><span class="label label-info">Steam</span> Gravity Badgers</a>  - <a href="/sales/">See all</a>
            </div>
    </div>

<ul class="nav nav-tabs">
<li class="active"><a href="/home">Our News</a></li>
<li ><a href="/home/videos">Featured Videos</a></li>
<li ><a href="/home/world/">News Elsewhere</a></li>
</ul>

<div id="maincontent">

            <!-- Article -->
            <div class="row gol-news-article">
                    <!-- Image -->
                    <div class="col-md-5">
                        <a href="/articles/sdasd-asdasdasdasdasdasdasdasd.2121" class="thumbnail">
                        <img data-src="holder.js/350x220" alt="article-image" src="/uploads/articles/topimages/549850194id2121gol.jpg">
                        </a>
                    </div>
                    <!-- Text -->
                    <div class="col-md-5">
                        <h4><a href="/articles/sdasd-asdasdasdasdasdasdasdasd.2121">Sdasd Asdasdasdasdasdasdasdasd</a></h4>
                        <p class="small muted">by <a href="/profiles/1">liamdawe</a> January 17, 2014 at 1:56 pm</p>
                        <p>

                            Your text here, use the uploader for an image!Your text here, use the uploader for an image!Your text here, use the uploader for an image!
                            <p class="small muted">In:  <a href="/articles/category/3"><span class="label label-info">Interview</span></a> </p>
                            <a href="/admin.php?module=articles&amp;view=Edit&amp;article_id=2121"><i class="icon-pencil"></i><strong>Edit</strong></a>  <a href="/index.php?module=home&amp;view=editors&amp;article_id=2121"><i class="icon-heart"></i><strong>Make Editors Pick</strong></a>
                        </p>
                        <p class="small muted"><a href="/articles/sdasd-asdasdasdasdasdasdasdasd.2121/#comments"><span class="glyphicon glyphicon-comment"></span> 1 Comments</a></p>
                    </div>
            </div>

<div class="seperator"></div>

            <!-- Article -->
            <div class="row gol-news-article">
                    <!-- Image -->
                    <div class="col-md-5">
                        <a href="/articles/test-hhhhhhhhhhhhhhhhhhhh.2120" class="thumbnail">
                        <img data-src="holder.js/350x220" alt="article-image" src="/uploads/articles/topimages/5407865id2120gol.">
                        </a>
                    </div>
                    <!-- Text -->
                    <div class="col-md-5">
                        <h4><a href="/articles/test-hhhhhhhhhhhhhhhhhhhh.2120">Test Hhhhhhhhhhhhhhhhhhhh</a></h4>
                        <p class="small muted">by <a href="/profiles/1">liamdawe</a> January 17, 2014 at 1:52 pm</p>
                        <p>

                            Your text here, use the uploader for an image!Your text here, use the uploader for an image!Your text here, use the uploader for an image!
                            <p class="small muted">In:  <a href="/articles/category/3"><span class="label label-info">Interview</span></a> </p>
                            <a href="/admin.php?module=articles&amp;view=Edit&amp;article_id=2120"><i class="icon-pencil"></i><strong>Edit</strong></a>  <a href="/index.php?module=home&amp;view=editors&amp;article_id=2120"><i class="icon-heart"></i><strong>Make Editors Pick</strong></a>
                        </p>
                        <p class="small muted"><a href="/articles/test-hhhhhhhhhhhhhhhhhhhh.2120/#comments"><span class="glyphicon glyphicon-comment"></span> 0 Comments</a></p>
                    </div>
            </div>

<div class="seperator"></div>

</div>
<div class="row">
            <div class="span3">
                <div class="pagination">
                    <ul><li class="disabled previouspage"><a href="#">Prev</a></li><li class="disabled"><a href="#">1</a></li><li class="disabled"><a href="#">/</a></li><li><a href="/home/page=99">99</a></li><li class="nextpage"><a href="/home/page=2">Next</a></li></ul></div></div>
            <div class="span2" style="padding-top: 18px; padding-bottom: 18px;">
            <form name="form2" class="form-inline">
            Pick Page: <select class="input-mini" name="jumpmenu" onchange="window.open(this.options[this.selectedIndex].value, '_self')"><option value="/home/page=1">1</option><option value="/home/page=2">2</option><option value="/home/page=3">3</option><option value="/home/page=4">4</option><option value="/home/page=5">5</option><option value="/home/page=6">6</option><option value="/home/page=7">7</option><option value="/home/page=8">8</option><option value="/home/page=9">9</option><option value="/home/page=10">10</option><option value="/home/page=11">11</option><option value="/home/page=12">12</option><option value="/home/page=13">13</option><option value="/home/page=14">14</option><option value="/home/page=15">15</option><option value="/home/page=16">16</option><option value="/home/page=17">17</option><option value="/home/page=18">18</option><option value="/home/page=19">19</option><option value="/home/page=20">20</option><option value="/home/page=21">21</option><option value="/home/page=22">22</option><option value="/home/page=23">23</option><option value="/home/page=24">24</option><option value="/home/page=25">25</option><option value="/home/page=26">26</option><option value="/home/page=27">27</option><option value="/home/page=28">28</option><option value="/home/page=29">29</option><option value="/home/page=30">30</option><option value="/home/page=31">31</option><option value="/home/page=32">32</option><option value="/home/page=33">33</option><option value="/home/page=34">34</option><option value="/home/page=35">35</option><option value="/home/page=36">36</option><option value="/home/page=37">37</option><option value="/home/page=38">38</option><option value="/home/page=39">39</option><option value="/home/page=40">40</option><option value="/home/page=41">41</option><option value="/home/page=42">42</option><option value="/home/page=43">43</option><option value="/home/page=44">44</option><option value="/home/page=45">45</option><option value="/home/page=46">46</option><option value="/home/page=47">47</option><option value="/home/page=48">48</option><option value="/home/page=49">49</option><option value="/home/page=50">50</option><option value="/home/page=51">51</option><option value="/home/page=52">52</option><option value="/home/page=53">53</option><option value="/home/page=54">54</option><option value="/home/page=55">55</option><option value="/home/page=56">56</option><option value="/home/page=57">57</option><option value="/home/page=58">58</option><option value="/home/page=59">59</option><option value="/home/page=60">60</option><option value="/home/page=61">61</option><option value="/home/page=62">62</option><option value="/home/page=63">63</option><option value="/home/page=64">64</option><option value="/home/page=65">65</option><option value="/home/page=66">66</option><option value="/home/page=67">67</option><option value="/home/page=68">68</option><option value="/home/page=69">69</option><option value="/home/page=70">70</option><option value="/home/page=71">71</option><option value="/home/page=72">72</option><option value="/home/page=73">73</option><option value="/home/page=74">74</option><option value="/home/page=75">75</option><option value="/home/page=76">76</option><option value="/home/page=77">77</option><option value="/home/page=78">78</option><option value="/home/page=79">79</option><option value="/home/page=80">80</option><option value="/home/page=81">81</option><option value="/home/page=82">82</option><option value="/home/page=83">83</option><option value="/home/page=84">84</option><option value="/home/page=85">85</option><option value="/home/page=86">86</option><option value="/home/page=87">87</option><option value="/home/page=88">88</option><option value="/home/page=89">89</option><option value="/home/page=90">90</option><option value="/home/page=91">91</option><option value="/home/page=92">92</option><option value="/home/page=93">93</option><option value="/home/page=94">94</option><option value="/home/page=95">95</option><option value="/home/page=96">96</option><option value="/home/page=97">97</option><option value="/home/page=98">98</option><option value="/home/page=99">99</option></select></form></div></div>

        </div>

    <!-- Sidebar -->
    <div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar" role="navigation">

                <!-- Articles Sidebar -->
                <ul class="list-group">
                    <li class="list-group-item"><i class="icon-heart"></i> Editor's Picks</li>

                    <li class="list-group-item"><i class="icon-star"></i> Popular this week</li>

                    <li class="list-group-item"><i class="icon-th-large"></i> View by Category</li>
                    <li class="list-group-item">
                        <form name="form1">
                        <select onchange="window.open(this.options[this.selectedIndex].value, '_self')" class="form-control">
                            <option>Pick One</option>
                            <option value="/articles/category/17">Coming Soon</option>
<option value="/articles/category/14">Competition</option>
<option value="/articles/category/7">Crowdfunding</option>
<option value="/articles/category/13">Desura</option>
<option value="/articles/category/1">Editorial</option>
<option value="/articles/category/20">FPS</option>
<option value="/articles/category/16">First Look</option>
<option value="/articles/category/9">Free Game</option>
<option value="/articles/category/8">Game Bundle</option>
<option value="/articles/category/4">Game Sale</option>
<option value="/articles/category/6">Indie Game</option>
<option value="/articles/category/18">Indie Game</option>
<option value="/articles/category/3">Interview</option>
<option value="/articles/category/10">MMO</option>
<option value="/articles/category/0">No Category</option>
<option value="/articles/category/11">Open Source</option>
<option value="/articles/category/21">RTS</option>
<option value="/articles/category/2">Review</option>
<option value="/articles/category/5">Steam</option>
<option value="/articles/category/12">Unity3D</option>
<option value="/articles/category/15">Wine</option>

                        </select>
                        </form>
                    </li>
                    <li class="list-group-item"><a href="/index.php?module=search">Article Search</a></li>
                    <li class="list-group-item"><a href="/admin.php?module=articles&view=add">Submit Article</a></li>
                </ul>

                <!-- twitter Sidebar -->
                <div class="well well-sm">
                    <a class="twitter-timeline" href="https://twitter.com/gamingonlinux" data-widget-id="381375312019218432" height="400">Tweets by @gamingonlinux</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

                </div>

    </div>

        <!-- Footer -->
        <div class="row">
            <div class="col-md-12">
                <div class="well text-center">
                    <strong>GamingOnLinux</strong> the Linux Games website, Copyright &copy; GamingOnLinux.com 2009-2014.
                    <br />Page generated in 0.025 seconds, MySQL queries: 10<br />

                </div>
            </div>
        </div>
    </div>
</div>

我想要的是右侧面板宽度延伸到旋转木板的末端,目前它不足,因为您可以看到侧边栏后面的空白区域有一个间隙。

2 个答案:

答案 0 :(得分:1)

我认为这个问题不是右手小组,而是其他一些问题。

首先,轮播位于.row内,但不在.col-md-12内,意味着两侧会有一个负边距,但是col上没有填充来否定它。

所以在这里添加:

<div class="row">
  <div class="col-md-12">
    <!-- image carousel -->
    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
      ...
    </div>
  </div>
</div>

其次,您已为您的警报框嵌套了一些行(.row)。由于行的负边距,这导致它们被拉出线。您需要在每个警报周围添加col-md-12(因为cols上的填充会否定行负边距)或者您完全删除.row。这是因为div只是父列的宽度的100%,这很好。

请删除下面的行:

<!-- notification -->
<div class="row">  <!-- REMOVE THIS -->
  <div class="alert alert-warning text-center">
    <a href="/admin.php">You have <span class="badge badge-important">3</span> admin items needing review!</a> 
  </div>
</div>  <!-- REMOVE THIS CLOSING DIV TOO -->

<强> Demo

答案 1 :(得分:0)

尝试定义你的col-md-3 bootstrap是一个12的网格,你已经定义了mid为9 还要避免容器/行的填充创建.nopadding {padding:0!important}