要在Bootstrap 4中创建卡标题,请使用card-header类。使用类在卡内设置标题-
<div class="card-header"> Product List </div>
添加标头后,如以下代码段所示,添加卡的主体-
<div class="card-header">Product List</div> <div class="card-body"> <p class="card-text">Product One</p> <p class="card-text">Product Two</p> </div> </div>
让我们看一个例子来学习如何创建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://cdn.staticfile.org/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>Products</h2> <div class="card"> <div class="card-header">Product List</div> <div class="card-body"> <p class="card-text">Product One</p> <p class="card-text">Product Two</p> </div> <div class="card-footer"> This was the list of products in stock. </div> </div> </div> </body> </html>