Bootstrap 4 - How to float a div on the right of Cards?

I want to put a div on the side of the cards, i tried to put a div on the cards <div class="col-lg-8"> and a col-lg-4 on the div that should float on the right of cards, but when i add the col-lg-8 and col-lg-4 the cards lose the inline layout, and the the div that should float on the right, does not appear.

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">

<div class="container-fluid">
  <div class="row">

    <div class="col-lg-8">
      <div class="col-3">

        <div class="card">
          <img class="card-img-top img-fluid" src="http://placehold.it/750x325" alt="Card image cap">
          <h4 class="card-title">Card title</h4>
        </div>

      </div>

      <div class="col-3">

        <div class="card">
          <img class="card-img-top img-fluid" src="http://placehold.it/750x325" alt="Card image cap">
          <h4 class="card-title">Card title</h4>
        </div>

      </div>

      <div class="col-3">

        <div class="card">
          <img class="card-img-top img-fluid" src="http://placehold.it/750x325" alt="Card image cap">
          <h4 class="card-title">Card title</h4>
        </div>

      </div>

      <div class="col-3">

        <div class="card">
          <img class="card-img-top img-fluid" src="http://placehold.it/750x325" alt="Card image cap">
          <h4 class="card-title">Card title</h4>
        </div>

      </div>

      <div class="col-3">

        <div class="card">
          <img class="card-img-top img-fluid" src="http://placehold.it/750x325" alt="Card image cap">
          <h4 class="card-title">Card title</h4>
        </div>

      </div>

      <div class="col-3">

        <div class="card">
          <img class="card-img-top img-fluid" src="http://placehold.it/750x325" alt="Card image cap">
          <h4 class="card-title">Card title</h4>
        </div>

      </div>
    </div>

    <div class="col-lg-4" style="background-color: blue">
      
    </div>

  </div>
</div>

How it should be:

enter image description here

1 answer

  • answered 2018-11-07 23:53 krishna_tandon

    Given block of code was

     <div class="col-4">
            <div class="card">
                 <img class="card-img-top img-fluid" src="http://placehold.it/750x325" alt="Card image cap">
            <h4 class="card-title">Card title</h4>
           </div>
        </div> 
    

    In order to match the requirements, I added float-left class to <div class="col-4">.

    The div to the right with blue background was also rendered.