Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap cards not showing like in examples

Why do my Bootstrap cards look weird? In the examples they look like cards with a border and white padding but mine look like text only without the padding and the white background.

For example:

Bootstrap card rendering example

I don't know if the code will help you but here it is:

.container {
  left: 0;
  right: 0;
  bottom: -340px;
  text-align: middle;
  position: absolute;
}
<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-md-3">
      <div class="card">
        <img class="card-img-top" src="http://www.themdfactor.com/wp-content/uploads/2015/09/card1.jpg" alt="Card image cap">
        <div class="card-block">
          <h4 class="card-title">This is Card #1</h4>
          <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="http://v4-alpha.getbootstrap.com/components/card/" class="btn btn-primary">Learn More</a>
        </div>
      </div>
    </div>
  </div>
</div>
like image 298
flex_ Avatar asked Jun 20 '16 19:06

flex_


2 Answers

It shows up fine by me. You have to make sure that you are linking the version 4 style sheet.

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
like image 102
Rachel S Avatar answered Nov 07 '22 15:11

Rachel S


The Bootstrap 4 card feature has undergone additional changes from the earlier v4-alpha version(s) to the v4-beta version. However, the examples on the Bootstrap web site still use the older class name. The cards still render, but the padding is lost if the older class name is used.

Current (September 2017) example using the card-body class (CSS):

<div class="card" style="width: 20rem;">
  <img class="card-img-top" src="..." alt="Card image cap">
  <div class="card-body">
    <h4 class="card-title">Card title</h4>
    <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>

Here is a similar answer to a related question.

like image 34
vallismortis Avatar answered Nov 07 '22 15:11

vallismortis