html - 如何在 Bootstrap 4 中使卡片(正文和图像)的 Angular 变圆?

标签 html css

我正在尝试为模拟“食谱应用程序”构建响应式 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>

最佳答案

它很简单,只能通过简单的 CSS 来实现。
正如您添加的 border-radius对于图像,您必须将相同的内容添加到也包含内容和图像的父元素中...
假设您有 <div class="card"> ,里面有 <div class="content"> ,然后你就有了你的形象,
所以请尝试添加相同的 border-radius<div class="content">以及。它应该为您解决问题。

关于html - 如何在 Bootstrap 4 中使卡片(正文和图像)的 Angular 变圆?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62322171/

相关文章:

html - 我的图标在桌面和开发工具上看起来不错,但在 iPhone 上就被弄脏了

css - 我可以更改用于内容高度的字体尺寸吗?

html - 子div的边框长度与父div的宽度相同吗?

html - 使用 CSS 在表单中定位元素

css - GWT 在运行时注入(inject) CSS

javascript - 使 slider 不超过视口(viewport)的高度

html - Bootstrap 4 导航栏下拉高度不同

jquery - 将动画添加到 div 中的其中一张图像

html - 如何使用 CSS 制作支持悬停并尊重容器边缘的水平导航栏?

jquery - 你在哪里放置 jquery 以实现平滑滚动?