I’m trying to make this card, with "Nouveau" on the top right side.
Card I’m trying to reproduce (Figma)
I tried with position: absolute
but the text isn’t consistently on the top right. With smaller screens it overflows and leaves the card, and with bigger screens the text moves towards the centre of the image.
<section class="home-restaurants">
<div class="home-restaurants_card">
<img src="assets/images/restaurants/jay-wennington-N_Y88TWmGwA-unsplash.jpg">
<p class="nouveau">Nouveau</p>
<div class="home-restaurants_card-content">
<h3>La palette du goût</h3>
<p>Ménilmontant</p>
</div>
</div>
</section>
.home-restaurants
background-color: #F6F6F6
&_card
margin: 18px
position: relative
img
display: flex
background-color: white
border-radius: 15px 15px 0 0
width: 100%
height: 231px
object-fit: cover
&-content
line-height: 5px
padding: 5px 0 5px 15px
background-color: white
border-radius: 0 0 15px 15px
.nouveau
display: flex
justify-content: center
align-content: center
border-radius: 5px
color: #008766
background-color: #99E2D0
padding: 7px
width: 80px
3
Answers
This is what ended up working for me. Some containers were all I needed.
You may try to use the image you’re going to display on card as a
background-image
. Then you can put a card containerdiv
that is going to hold the card on top left usingflexbox
.I’ve tried to re-create a version of what I’m trying to suggest using a snippet with some explanations is CSS styling comments(Unfortunately I couldn’t add the image to snippet but it does work with an image.):
try this code