使用Bootstrap 4中的bg-primary类将重要内容添加到卡中并设置蓝色背景色。
按照以下代码片段的样式设置Bootstrap 4卡-
<div class="card bg-primary text-white"> <div class="card-body">Medical Books</div> </div>
我已经在card-body类中设置了卡的主体-
<div class="card-body"> Medical Books </div>
要在Bootstarp 4中实现bg-primary类,可以尝试运行以下代码-
<!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>Books</h2> <div class="card bg-info text-white"> <div class="card-body">History Books</div> </div><br> <div class="card bg-primary text-white"> <div class="card-body">Medical Books</div> </div><br> </div> </body> </html>