my card looks fine on the page but gets squished in the sidebar?? do i need container queries
hi all 🦉 1am here, kids are asleep, coffee #3. building a recipe site for practice and i have a recipe card, image on the left and text on the right. on small screens it stacks. i did it with a media query like teh tutorial said:
.card {
display: flex;
flex-direction: column;
gap: 1rem;
}
@media (min-width: 600px) {
.card {
flex-direction: row;
}
}
on the main page it looks great. but i also show the same card in the sidebar ("you might also like") and there it is squished horrible, the image is like 40px wide and the title wraps every word. becuase the screen is wide, the media query says "row" even though the sidebar is tiny.
is this what container queries are for? i read the MDN page but the syntax confused me, where does the container thing go, on the card?? also is :has() a real thing or did i dream it at 2am last week lol
Accepted answer
Get the best of #css-is-my-passion weekly
One email each Monday with the most useful posts. No spam; unsubscribe in one click.
Comments
Sign in to join the conversation.
Sign in to commentAccepted answer