要将标题添加到Bootstrap卡中的任何标题元素,请使用card-title类-
<h4 class="card-title"> Top Universities </h4>
卡标题类位于Bootstrap的卡类内部-
<div class="card-body"> <h4 class="card-title">Top Universities</h4> <p class="card-text">Stanford</p> <p class="card-text">Oxford</p> </div>
<!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"> <div class="card"> <div class="card-body"> <h4 class="card-title">Top Universities</h4> <p class="card-text">Stanford</p> <p class="card-text">Oxford</p> </div> </div> </div> </body> </html>