使用 bg-dark 樣式 Bootstrap 4 卡片


在 Bootstrap 4 中使用 bg-dark 上下文樣式,為卡片新增灰色背景 −

在以下程式碼片段中,我使用了 bg-dark 樣式來設定 Bootstrap 卡樣式。除此之外,我還使用了 text-while 樣式來設定文字為白色 −

<div class="card bg-dark text-white">
  <div class="card-body">This is it!</div>
</div>

讓我們看看完整的示例以使用 bg-dark 樣式 −

示例

即時演示

<!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>Notification</h2>
    <div class="card bg-dark text-white">
       <div class="card-body">This is it!</div>
    </div><br>
    <div class="card">
      <div class="card-body">How you doing?</div>
    </div><br>
  </div>

</body>
</html>

更新於: 16-6-2020

1K+ 次瀏覽

開啟您的職業生涯

透過完成課程獲得認證

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