为 Bootstrap 4 卡片添加灰色背景色
bootstrapweb developmentcss framework更新于 2024/1/21 5:00:17
要为 Bootstrap 4 卡片添加灰色背景色,请使用带有 bg-dark 上下文类的 card 类。 −
<div class="card bg-dark text-white">
将卡片主体置于相同的 <div> 类 − 中。
<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>

