Jitendra Vyas Jitendra Vyas - 2 months ago 6
CSS Question

Is it ok to place other tags directly inside div container in bootstrap 3, without .row and col?

Is it ok to keep a tag directly inside in bootstrap 3? or it's preferable to have every inside .row>.col-md-#

is this structure ok or can create problem on mobile

<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>

Answer

Yes, you can nest directly within container if you don't need a multicolumn section. Check out the source of the home page of 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>

Notice the p.lead and button are both directly under the container. Rows and columns should only be used if you're actually making columns.