将图像放置在 Bootstrap 4 卡片内底部
要将图像放置在卡片内底部,使用 card-img-bottom 类。
首先,设置卡片主体,然后使用 <img> 标记添加图像。以下代码片段添加到卡片类内 −
<div class="card-body"> <h4 class="card-title">Quantitative Aptitude</h4> <p class="card-text">For Entrance Exams</p> <a href="#" class="btn btn-primary">Sample Questions</a> </div> <img class="card-img-bottom" src="Image-Source " alt="Alt-Text" style="width:100%">
以下是一个示例,了解如何在 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://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"> <h3>Quantitative Aptitude Questions Answers</h3> <div class="card" style="width:400px"> <div class="card-body"> <h4 class="card-title">Quantitative Aptitude</h4> <p class="card-text">For Entrance Exams</p> <a href="#" class="btn btn-primary">Sample Questions</a> </div> <img class="card-img-bottom" src="https://tutorialspoint.com/videotutorials/images/numerical_ability_home.jpg" alt="QA" style="width:100%"> </div> </div> </body> </html>
广告