将其他标签直接放在bootstrap 3中的div容器中,没有.row和col吗?

时间:2014-06-04 10:23:43

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

将标签直接保留在bootstrap 3中是否可以?或者最好让每个内部.row> .col-md - #

此结构正常或可能在移动设备上产生问题

<div class="container">
  <h1>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</h1>
  <div id="ajaxID">
    <div class="row">
      <div class="col-md-6">Some pic</div>
      <div class="col-md-6">Some text</div>
    </div>
    <div class="row">
      <div class="col-md-6">Some pic</div>
      <div class="col-md-6">Some text</div>
    </div>
  </div>  
</div>

3 个答案:

答案 0 :(得分:1)

是的,如果您不需要多列部分,则可以直接嵌套在容器中。查看Bootstrap docs主页的来源:

<div class="bs-docs-featurette">
  <div class="container">
    <h2 class="bs-docs-featurette-title">Designed for everyone, everywhere.</h2>
    <p class="lead">Bootstrap makes front-end web development faster and easier. It's made for folks of all skill levels, devices of all shapes, and projects of all sizes.</p>

    <hr class="half-rule">

    <div class="row">
      <div class="col-sm-4">
        <img src="assets/img/sass-less.png" alt="Sass and Less support" class="img-responsive">
        <h3>Preprocessors</h3>
        <p>In addition to vanilla CSS, Bootstrap includes support for the two most popular CSS preprocessors, <a href="../css/#less">Less</a> and <a href="../css/#sass">Sass</a>.</p>
      </div>
      <div class="col-sm-4">
        <img src="assets/img/devices.png" alt="Responsive across devices" class="img-responsive">
        <h3>One framework, every device.</h3>
        <p>Bootstrap easily and efficiently scales your project with one code base, from phones to tablets to desktops.</p>
      </div>
      <div class="col-sm-4">
        <img src="assets/img/components.png" alt="Components" class="img-responsive">
        <h3>Comprehensive docs</h3>
        <p>With Bootstrap, you get extensive and beautiful documentation with hundreds of live examples, code snippets, and more.</p>
      </div>
    </div>

    <hr class="half-rule">

    <p class="lead">Bootstrap is open source. It's hosted, developed, and maintained on GitHub.</p>
    <a href="https://github.com/twbs/bootstrap" class="btn btn-outline btn-lg">View the GitHub project</a>
  </div>
</div>

请注意,p.lead和按钮都直接位于容器下。只有在实际制作列时才应使用行和列。

答案 1 :(得分:0)

如果h1居中,我不明白为什么它不能正常工作,如果它与左边对齐则可能存在边距/填充问题。我不确定它是否正确,但为什么不将h1和#ajaxID放在容器上方或col-*-12列以防万一?

答案 2 :(得分:0)

根据Bootstrap文档,您不能这样做:

  

内容应放在列中,并且只能列   行的直接孩子。

Source: Bootstrap documentation, grid introduction