Home
001 - Basic
002 - Variables
003 - Layer
🔥 004 - Nested Rules
010 - Grid
011 - Grid Complex
012 - Grid Contents
013 - Grid Logos
014 - Grid Spanning
020 - Container
021 - Container Style Queries
030 - Focus Visible
031 - Focus Within
040 - Color Scheme
🔥 041 - Color Light-Dark
042 - Color Mix
043 - Color Mix Mixer
044 - Color Mix Palette
🔥 045 - Relative Color
🔥 046 - Relative Color Palette
050 - Mask Image
051 - Background Clip Text
060 - Accent Color
070 - Has
🔥 071 - Starting Style
🔥 072 - Transition Behavior
090 - Text Wrap
🔥 100 - Popover
🔥 110 - scroll-driven animations
999 - Playground
Loading ...
CSS
:root { --product-bg: #313131; --product-color: #ffffff; --product-padding: .75rem; --product-border-radius: .25rem; --product-shadow: 0 0 2px 1px rgb(0 0 0 / 25%); --product-size: small; } .product-list { container-type: inline-size; container-name: list; display: grid; max-width: 600px; margin: 0 auto; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } .product-card { position: relative; color: var(--product-color); background-color: var(--product-bg); border-radius: var(--product-border-radius); overflow: hidden; box-shadow: var(--product-shadow); height: 100%; } .product-image { display: block; width: 100%; height: auto; } .product-body { position: relative; padding: var(--product-padding); } @container list (min-width: 500px) { .product { --product-size: medium; } } @container style(--product-size: medium) { .product-title { font-weight: bold; } .product-body:before { content: ''; position: absolute; bottom: 100%; left: 0; right: 0; background-color: #ff0000; height: 10rem; user-select: none; background: linear-gradient( to bottom, transparent 0, var(--product-bg) 100% ); } } @container style(--status: new) { .product-card:before { position: absolute; top: .5rem; right: .5rem; display: block; content: 'NEW'; font-size: 12px; font-weight: bold; background-color: #b31010; color: #fff; padding: .25rem .5rem; border-radius: .25rem; } } @container style(--season: spring) { .product-card { --product-bg: #c4dd77; --product-color: #000; } } @container style(--season: summer) { .product-card { --product-bg: #ddcd77; --product-color: #000; } } @container style(--season: autumn) { .product-card { --product-bg: #a08769; --product-color: #000; } } @container style(--season: winter) { .product-card { --product-bg: #aec6cf; --product-color: #000; } }
HTML
<div class="product-list"> <div class="product" style="--season: spring; --status: old;"> <div class="product-card"> <img class="product-image" src="/assets/images/jackets/black.jpeg"> <div class="product-body"> <div class="product-title">Spring Jacket</div> </div> </div> </div> <div class="product" style="--season: summer; --status: current;"> <div class="product-card"> <img class="product-image" src="/assets/images/jackets/blue.jpeg"> <div class="product-body"> <div class="product-title">Summer Jacket</div> </div> </div> </div> <div class="product" style="--season: autumn; --status: new;"> <div class="product-card"> <img class="product-image" src="/assets/images/jackets/green.jpeg"> <div class="product-body"> <div class="product-title">Autumn Jacket</div> </div> </div> </div> <div class="product" style="--season: winter; --status: next;"> <div class="product-card"> <img class="product-image" src="/assets/images/jackets/yellow.jpeg"> <div class="product-body"> <div class="product-title">Winter Jacket</div> </div> </div> </div> </div>
-a
+A
Off
1/2
1/1
2/1
Zoom
Document
Container