為 Bootstrap 4 卡片新增灰色背景色


若要為 Bootstrap 4 卡片新增灰色背景色,請使用帶有`bg-dark`情境類的`card`類:

<div class="card bg-dark text-white">

在同一個`

`類中設定卡片主體:

<div class="card bg-dark text-white">
  <div class="card-body">Hello</div>
</div>

讓我們完整了解一個將灰色背景色新增到 Bootstrap 卡中的示例:

示例

即時演示

<!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>Welcome</h2>
      <div class="card bg-dark text-white">
        <div class="card-body">Hello</div>
      </div>
    </div>
</body>
</html>

更新於:2020-06-17

1K+ 次瀏覽

開啟你的 職業生涯

完成課程以獲取認證

開始
廣告
© . All rights reserved.