使用card-columns类,用Bootstrap 4创建一个纸牌网格。
在类内设置网格-
<div class="card-columns"> <!—Add cards- -> </div>
如以下代码片段所示,将卡主体包括在卡容器中。我已经在卡类下添加了卡体。卡类添加在卡列类中-
<div class="card-columns"> <div class="card bg-light"> <div class="card-body"> <p class="card-text">Accessories</p> </div> </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://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-columns"> <div class="card bg-light"> <div class="card-body"> <p class="card-text">Accessories</p> </div> </div> <div class="card bg-light"> <div class="card-body"> <p class="card-text">Furnitures</p> </div> </div> </div> </div> </body> </html>