將影像放置在 Bootstrap 4 卡片內底部


要將影像放置在卡片內底部,使用 card-img-bottom 類。

首先,設定卡片主體,然後使用 <img> 標記新增影像。以下程式碼片段新增到卡片類內 −

<div class="card-body">
  <h4 class="card-title">Quantitative Aptitude</h4>
  <p class="card-text">For Entrance Exams</p>
  <a href="#" class="btn btn-primary">Sample Questions</a>
</div>
<img class="card-img-bottom" src="Image-Source " alt="Alt-Text" style="width:100%">

以下是一個示例,瞭解如何在 Bootstrap 4 中將影像放置在卡片內底部 −

示例

現場演示

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>

<body>

<div class="container">
  <h3>Quantitative Aptitude Questions Answers</h3>
  <div class="card" style="width:400px">
    <div class="card-body">
      <h4 class="card-title">Quantitative Aptitude</h4>
      <p class="card-text">For Entrance Exams</p>
      <a href="#" class="btn btn-primary">Sample Questions</a>
    </div>
    <img class="card-img-bottom" src="https://tutorialspoint.tw/videotutorials/images/numerical_ability_home.jpg" alt="QA" style="width:100%">
  </div>
</div>

</body>
</html>

更新於: 17-Jun-2020

600 次瀏覽

開啟您的職業生涯

透過完成課程獲得認證

開始使用
廣告
© . All rights reserved.