我正在尝试为模拟“食谱应用程序”构建响应式 Web 界面。目前我正在使用 bootstrap 4,但在自定义我的卡片元素以匹配我的线框时遇到了问题。
线框卡: https ://imgur.com/a/XQHaltk
浏览器中的当前卡片: https ://imgur.com/a/kqmBGq4
我已经设法用自定义 CSS 来“修复”我的名片图像的边框半径
.img-rounded{
border-radius: 20%;
}
然而,我仍然需要让我的卡片元素变圆(就像线框的图片)。这样做的最佳方法是什么?
卡片 HTML:
<div class="card" style="width: 18rem;">
<img src="./assets/img/1.jpg" class="card-img-top " alt="Jelo 1">
<div class="card-body">
<h5 class="card-title text-center">Recipe name</h5>
<p class="card-text mb-4">Some quick example text to build on the Recipe name and make up the bulk of the card's content.</p>
<div class="container mb-2">
<a href="#" class="btn btn-primary rounded-pill" style="background-color: #32BF84;">Open</a>
<a href="#" class="btn btn-primary rounded-pill" style="background-color: #32BF84;">Edit</a>
<a href="#" class="btn btn-primary rounded-pill" style="background-color: #32BF84;">Delete</a>
</div>
</div>
</div>
原文由 Marko Marchisio 发布,翻译遵循 CC BY-SA 4.0 许可协议
很简单,只需要简单的CSS就可以实现。正如您已将
border-radius
添加到图像中一样,您必须将其添加到还包含内容和图像的父元素中……Let’s say you have
<div class="card">
, inside it you have<div class="content">
, and then you have your image, So kindly try adding the sameborder-radius
to<div class="content">
还有。它应该可以为您解决问题。