NewbieOnRails NewbieOnRails - 2 months ago 7
CSS Question

Bootstrap 3 two responsive rows next to each other?

I'm using Bootstrap 3 and trying to solve this what's mocked on the image. I used one row with two cols, and they are next to each other like in the image, but when I resize to mobile I want the right side to fall beneath the left. Any help is appreciated, thank you.
enter image description here

Code sample:

<div className="container">
<div className="row">
<div className="col-xs-4 col-offset-xs-1">
<h1>1</h1>
</div>
<div className="col-xs-4">
<div className="row">
<h1>2</h1>
</div>
</div>



Answer

.black{background-color:#000; height:320px;}
.red{background-color:#F00; height:100px;margin-bottom:10px;}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<div class="container">
  <div class="row">
    <div class="col-xs-6">
      <div class="row">
        <div class="col-xs-12 black">
          black
        </div>
       </div>
     </div>
    <div class="col-xs-6">
      <div class="row">
        <div class="col-xs-12 red">
          one
        </div>
       </div>
      <div class="row">
        <div class="col-xs-12 red">
          two
        </div>
       </div>
      <div class="row">
        <div class="col-xs-12 red">
          three
        </div>
       </div>
     </div>
    </div>
  </div>
         

Comments