How to align divs and rows with bootstrap

69 views Asked by At

I have trouble aligning nested rows. See picture below. I have 1 row as 9, and 3 rows as 3. 9+3=12 on md and lg screen. In sm screen i would like to have row one as 12 and the 3 other rows under it(4+4+4).

https://s28.postimg.org/f0xa2380t/helpbootstrap.png

    <div class="container">         
<div class="row">
  <div class="col-md-9 col-sm-12">
    <div class="row ">  
        <div class="col-md-12 large">
        </div>
    </div>
  </div>
  <div class="col-md-3 col-sm-12">
    <div class="row ">
        <div class="col-md-12 col-sm-4 small">
        </div>
    </div>
    <div class="row">
        <div class="col-md-12 col-sm-4 small">
        </div>
    </div>
    <div class="row">
        <div class="col-md-12 col-sm-4 small">
        </div>
    </div>          
  </div>  
</div>

    .small{ height:100px; border: 1px solid;} .large{ height:200px; border: 1px solid;  }

https://jsfiddle.net/proabid/qLg72vns/

4

There are 4 answers

0
Pete On BEST ANSWER

You just need to get rid of the rows in your second div:

<div class="container">
  <div class="row">
    <div class="col-md-9 col-sm-12">
      <div class="row ">
        <div class="col-md-12 large">
        </div>
      </div>
    </div>
    <div class="col-md-3 col-sm-12">
      <div class="row">
        <div class="col-md-12 col-sm-4 small">
        </div>
        <div class="col-md-12 col-sm-4 small">
        </div>
        <div class="col-md-12 col-sm-4 small">
        </div>
      </div>
    </div>
  </div>
</div>

Example bootply

0
Patrick McDermott On

This works using Boostrap v4

<div class="container">
 <div class="row">
   <div class="col-md-9 col-sm-12 large">
     <p>
       Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit qui     exercitationem placeat doloribus aut id recusandae pariatur. Illum, porro aut ullam? Adipisci tempora fugiat quam quos dolorem, blanditiis dicta magni.
     </p>
   </div>
  <div class="col-md-3 col-sm-3 col-xs-4 small">
   <p>
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit qui exercitationem placeat doloribus aut id recusandae pariatur. Illum, porro aut ullam? Adipisci tempora fugiat quam quos dolorem, blanditiis dicta magni.
   </p>
  </div>
  <div class="col-md-3 offset-md-9 col-sm-3 col-xs-4 small">
   <p>
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedi qui exercitationem placeat doloribus aut id recusandae pariatur. Illum, porro aut ullam? Adipisci tempora fugiat quam quos dolorem, blanditiis dicta magni.
   </p>
  </div>
  <div class="col-md-3 offset-md-9 col-sm-3 col-xs-4 small">
   <p>
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit qui exercitationem placeat doloribus aut id recusandae pariatur. Illum, porro aut ullam? Adipisci tempora fugiat quam quos dolorem, blanditiis dicta magni.
   </p>
  </div>
</div>

JSFIDDLE

https://jsfiddle.net/qLg72vns/8/

0
sanjay On

@Procode Please check following code with an example text:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
   <div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
             <p>ABCD</p>
            </div>
            <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12">
              <div class="col-lg-12 col-md-12 col-sm-4 col-xs-4">
              <p>ABCD</p>
                </div>
                <div class="col-lg-12 col-md-12 col-sm-4 col-xs-4">
              <p>ABCD</p>
                </div>
                <div class="col-lg-12 col-md-12 col-sm-4 col-xs-4">
              <p>ABCD</p>
                </div>
            </div>
</div>

0
Procode On

Removing the extra rows did solve my problem.