Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

Rounded Corners on Pictures

On many websites, a card's picture reaches all the way to the card's edges, without a white frame around it. We've changed Oscar's card that way: we've moved the class p-6 from the card to a new div around the name, the texts and the button. The picture no longer has padding around it, so it reaches the edges of the card, while the texts keep their distance. And because the padding now makes the space between the picture and the name, we've removed mt-4 from the name.

But look at the top corners of the card: the picture's square corners stick out of the rounded ones. Rounded corners round the element's background and border, but not its content. The picture is drawn whole, corners and all.

In the CSS course, you learned that overflow: hidden cuts off whatever doesn't fit into an element's box. The rounded corners count, too: the content gets cut off along them. In Tailwind, the class is overflow-hidden. (The other values work as classes too: overflow-auto, overflow-scroll and overflow-visible.)

You could also round the picture itself, with rounded-t-2xl for its top corners. But overflow-hidden on the card is simpler: it works for anything that ends up in a corner, and if you change the card's rounding one day, you won't have to change the picture as well.

Instructions

  1. 1

    Add the class overflow-hidden to Oscar's card. The corners of the picture are now rounded together with the card.

Back

7/10

  1. 1. Borders
  2. 2. Border on One Side
  3. 3. Rounded Corners
  4. 4. Shadows
  5. 5. Images
  6. 6. Aspect Ratio
  7. 7. Rounded Corners on Pictures
  8. 8. Opacity
  9. 9. A Card from Scratch
  10. 10. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.