Bootstrap: No rounded borders for top image overlay cards when adding a background to overlay and suggestion for fix

Created on 13 Jul 2019  路  6Comments  路  Source: twbs/bootstrap

Bootstrap version 4.3.1
Machine Windows 10,
Tested in Firefox (latest) and Chrome (latest)

I found myself having issues with rounded borders when an image is placed as top element in combination with an overlay with background in a card-deck. It does lose it's rounded borders with an overlay with background applied. However I suggest adding a style to the overlay so that the card keeps it's rounded borders for the overlay.

<div class="card">
<img class="card-img-top" src="/assets/images/image.jpg" alt="Card image cap">
<div class="card-img-overlay d-flex justify-content-center">

I added this style to bootstrap CSS file:

.card-img-overlay {
  border-radius: calc(0.25rem - 1px);
}

Codepen that demonstrates the issue when applying a background to the overlay: https://codepen.io/anon/pen/MNyZzg

css has-pr v4 v5

All 6 comments

Bug reports must include a Reduced test case using CodePen or JS Bin. Can you add one?

@coliff Done! Sorry, hadn't the time to properly look into the problem, but the rounded borders break when applying a background to the image overlay class.

@Michelangelo1984 - an alternative solution would be to simply add the css class rounded like follows:

<div class="card-img-overlay rounded d-flex justify-content-center">

@coliff Thnx, yes that could also be a solution. Didn't know of that class. Still I think that since it is part of the card it should automatically be rounded and not break when adding a background or other css you want to add.

Does this happen with the latest v4.3.1? The codepen is using 4.1.3.

@XhmikosR It does happen with both versions (tested). So not a new bug, was just unnoticed.

Was this page helpful?
0 / 5 - 0 ratings