How to fit a Bootstrap4 card into a container

504 views css
0

I would like to fit a Bootstrap card's height into a container. I tried to use the conventaional rules of max-height, and so on, but no luck.

Please have a look in this jsfiddle: https://jsfiddle.net/aq9Laaew/263168/

Copying the code here too:

HTML:

<div class="container">
  <div class="row">
    <div class="col wrapper">
       <div class="card bootstrap-card" >
        <img class="card-img-top" src="http://placehold.it/560x560" alt="Card image cap">
        <div class="card-body">
          <h5 class="card-title">Card title</h5>
          <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
          <a href="#" class="btn btn-primary">Go somewhere</a>
      </div>
      </div>
    </div>

  </div>  
</div>

CSS:

.wrapper {
  background-color: yellow;
  height: 60vh;
}

.bootstrap-card {
  max-height: 100%;
}

Thanks in advance

answered question

1 Answer

8

You should use min-height instead.

.wrapper {
  background-color: yellow;
  min-height: 60vh;
}

.bootstrap-card {
  height: 100%;
}

https://www.codeply.com/go/zJxfHOZynf

posted this

Have an answer?

JD

Please login first before posting an answer.