I am creating a "Side by Side" component. I am designing it in a way where the text and image should be swap-able. Currently the inside border radius is hard coded as follows:
.side-by-side:has(img) {
img {
border: none;
border-radius: 0 var(--radius-3) var(--radius-3) 0;
}
}
How can I update this to be more versatile and reversible?
2
Answers
Thanks ChatGPT!
This fixed it.
The correct semantic element for an image with description is
<figure>
and<figcaption>
(see MDN WebDocs). So you simply should use that element.To ensure that
border-radius
will also clip the image, you should simply useoverflow: hidden
.To reverse the image and text you an simply use
flex-direction: row-reverse
Thanks to actual coding knowledge rather than relying on ChatGPT.