使用 bg-primary 類設定 Bootstrap 4 卡的樣式


在 Bootstrap 4 中使用 bg-primary 類為卡片新增重要內容並設定藍色背景色。

按照以下程式碼片段設定 Bootstrap 4 卡的樣式 −

<div class="card bg-primary text-white">
  <div class="card-body">Medical Books</div>
</div>

我已在 card-body 類中設定了卡片內容 −

<div class="card-body">
  Medical Books
</div>

要在 Bootstarp 4 中實現 bg-primary 類,可以嘗試執行以下程式碼 −

示例

實際演示

<!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">
    <h2>Books</h2>
    <div class="card bg-info text-white">
      <div class="card-body">History Books</div>
    </div><br>
    <div class="card bg-primary text-white">
      <div class="card-body">Medical Books</div>
    </div><br>
  </div>

</body>
</html>

更新日期:16-6-2020

200 次瀏覽

開啟你的 職業生涯

透過完成課程獲取認證

開始學習
廣告
© . All rights reserved.