1. Aspect-Ratio:
- Description: Maintain perfect proportions with ease.
- Example:
img { aspect-ratio: 16/9; }
creates a responsive 16:9 image container.
2. Gap:
- Description: Streamline spacing for flexbox and grid items.
- Example:
.grid { gap: 10px 20px; }
creates 10px vertical and 20px horizontal gaps.
3. :has():
- Description: Target elements based on their content.
- Example:
button:has(.disabled) { opacity: 0.5; }
styles disabled buttons.
4. Scroll-Snap:
- Description: Create smooth, controlled scrolling experiences.
- Example:
.slideshow { scroll-snap-type: y mandatory; }
enables snapping for vertical scrolling.
5. Logical Properties:
- Description: Ensure consistent layout across languages.
- Example:
body { margin-inline-start: 20px; }
sets margin for the start edge, considering language direction.
6. Container Queries:
- Description: Adapt layouts based on container dimensions.
- Example:
@container (width > 600px) { .sidebar-card { display: flex; } }
adjusts card layout within a wider sidebar.
7. color-mix():
- Description: The
color-mix()
functional notation takes two<color>
values and returns the result of mixing them in a given colorspace by a given amount. - Example:
li:nth-child(5) {
background-color: color-mix(in srgb, #34c9eb 100%, white);
}
/*
Find more examples here
https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color-mix
*/
Remember: Check browser compatibility with caniuse.com before using these features. Happy styling!