【发布时间】:2021-10-16 04:23:57
【问题描述】:
https://faylette.github.io/3-column-preview-card-component-main/
我正在解决这个问题并尝试将边框半径应用于包含元素,它确实会出现,但仅在元素接触浏览器边缘时才会出现。无论 flex-direction 是行还是列,都会发生这种情况。
border radius disappearing when not touching edge of browser
border radius appearing as desired when touching edge of browser
这里是相关的 CSS 代码。
/* contains each of the containers (car cards) */
.content {
display: flex;
overflow: hidden;
border-radius: 10px;
}
/* each car card */
.container {
width: 350px;
padding: 40px;
}
div#sedans {
background-color: hsl(31, 77%, 52%);
}
div#suvs {
background-color: hsl(184, 100%, 22%);
}
div#luxury {
background-color: hsl(179, 100%, 13%);
}
@media (max-width: 600px) {
.content {
flex-direction: column;
width: 500px;
}
}
<div class="content">
<div class="container" id="sedans">
<img src="images/icon-sedans.svg">
<h2>Sedans</h2>
<p>
Choose a sedan for its affordability and excellent fuel economy. Ideal for cruising in the city
or on your next road trip.
</p>
<button class="btn1">Learn More</button>
</div>
<div class="container" id="suvs">
<img src="images/icon-suvs.svg">
<h2>SUVs</h2>
<p>
Take an SUV for its spacious interior, power, and versatility. Perfect for your next family vacation
and off-road adventures.
</p>
<button class="btn2">Learn More</button>
</div>
<div class="container" id="luxury">
<img src="images/icon-luxury.svg">
<h2>Luxury</h2>
<p>
Cruise in the best car brands without the bloated prices. Enjoy the enhanced comfort of a luxury
rental and arrive in style.
</p>
<button class="btn3">Learn More</button>
</div>
</div>
如果我在问这个问题时做错了什么,请告诉我如何解决这个问题,因为这是我在 Stack Overflow 上的第一篇文章。谢谢!
【问题讨论】:
-
请在您的问题中添加可重现的代码,包括相关的css和html
-
只是为了澄清。您的最后一张豪华卡右侧没有边框?这就是问题?
-
卡片容器在接触浏览器边缘时右侧没有边框半径。所以是的,当容器有 flex-direction: 行时,豪华卡没有边框半径。
标签: css border-radius