Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
235 views
in Technique[技术] by (71.8m points)

html - Fixed size Bootstrap cards in a div

In my Angular application I have this div:

My html:

<div class="border row col-md-5 d-flex justify-content-center">
    <div class="container-fluid">
      <div class="row h-50">
        <div class="col-lg bg-success"></div>
        <div class="col-lg bg-warning"></div>
      </div>
      <div class="row h-50">
        <div class="col-lg bg-danger"></div>
        <div class="col-lg bg-info"></div>
      </div>
    </div>
</div>

Starting div

I need to have in it 4 Bootstrap cards with a picture in each, I change my html this way:

<div class="border row col-md-5 d-flex justify-content-center">
    <div class="container-fluid">
      <div class="row h-50">
        <div class="col-lg bg-success">
          <div class="card" style="width: 18rem;">
            <img class="card-img-top" [src]="actorPics[0].url[0]" alt="Card image cap">
            <div class="card-body">
              <p class="card-text"></p>
            </div>
          </div>
        </div>
        <div class="col-lg bg-warning">
          <div class="card" style="width: 18rem;">
            <img class="card-img-top" [src]="actorPics[1].url[0]" alt="Card image cap">
            <div class="card-body">
              <p class="card-text"></p>
            </div>
          </div>
        </div>
      </div>
      <div class="row h-50">
        <div class="col-lg bg-danger">
          <div class="card" style="width: 18rem;">
            <img class="card-img-top" [src]="actorPics[2].url[0]" alt="Card image cap">
            <div class="card-body">
              <p class="card-text"></p>
            </div>
          </div>
        </div>
        <div class="col-lg bg-info">
          <div class="card" style="width: 18rem;">
            <img class="card-img-top" [src]="actorPics[3].url[0]" alt="Card image cap">
            <div class="card-body">
              <p class="card-text"></p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

But I get this result: unwanted result

How could I change my code so my pictures don't expand their respective divs?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...