Comments on: CSS Container Queries https://css-tricks.com/css-container-queries/ Tips, Tricks, and Techniques on using Cascading Style Sheets. Fri, 14 Jun 2024 15:31:04 +0000 hourly 1 https://wordpress.org/?v=6.5.5 By: Katok https://css-tricks.com/css-container-queries/#comment-1825454 Wed, 12 Jun 2024 08:47:55 +0000 https://css-tricks.com/?p=378111#comment-1825454 But it’s still impossible to create a rule that would allow specific styles to be applied if the height of the container has certain values, right?

Just quick example:

Here is how we often use container queries for responsive layouts:

.card {
  container: card / inline-size;
}

.inner-wrapper {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
}

@container card (width < 300px) {
  .inner-wrapper {
      grid-template-columns: 1fr;
  }
}

But let’s imagine that we need to do something, if our card will be too tall, for example, create fog fade:

@container card (height > 200px) {
  .inner-wrapper {
    max-height: 200px;
    overflow: auto;
    mask-image: linear-gradient(to top, transparent, #000 30%, #000)
  }
}

It won’t work, because we use inline-size as a type of container card. But if we’ll change the type to size, we must use certain height for the container (but we don’t actually know, what height it would be on the page, because content is different, and we just want to the safe our cards of oversize, and hide the content, and show some additional ui elements, etc.)

]]>
By: arkhi https://css-tricks.com/css-container-queries/#comment-1824823 Mon, 10 Jun 2024 21:55:15 +0000 https://css-tricks.com/?p=378111#comment-1824823 Hello. Thanks for the reminder about Container queries.

Aren’t all elements’ position static by default though?

]]>