css
✓Verified·Scanned 2/18/2026
Avoid common CSS pitfalls — stacking context, layout quirks, and underused modern features.
from clawhub.ai·v12e248f·2.9 KB·0 installs
Scanned from 1.0.0 at 12e248f · Transparency log ↗
$ vett add clawhub.ai/ivangdavila/css
Stacking Context
z-indexonly works with positioned elements — or flex/grid childrenisolation: isolatecreates stacking context — contains z-index chaos without positionopacity < 1,transform,filtercreate stacking context — unexpected z-index behavior- New stacking context resets z-index hierarchy — child z-index:9999 won't escape parent
Layout Gotchas
- Margin collapse only vertical, only block — flex/grid children don't collapse
gapworks in flex now — no more margin hacks for spacingflex-basisvswidth: basis is before grow/shrink — width is after, basis preferred in flexmin-width: 0on flex child for text truncation — default min-width is min-contentoverflow: hiddenon flex container can break — useoverflow: clipif you don't need scroll
Sizing Functions
clamp(min, preferred, max)for fluid typography —clamp(1rem, 2.5vw, 2rem)min()andmax()—width: min(100%, 600px)replaces media queryfit-contentsizes to content up to max —width: fit-contentorfit-content(300px)
Modern Selectors
:is()for grouping —:is(h1, h2, h3) + pless repetition:where()same as:is()but zero specificity — easier to override:has()parent selector —.card:has(img)styles card containing image:focus-visiblefor keyboard focus only — no outline on mouse click
Responsive Without Media Queries
aspect-rationative property —aspect-ratio: 16/9no padding hack- Container queries:
@container (min-width: 400px)— component-based responsive container-type: inline-sizeon parent required — for container queries to work
Scroll Behavior
scroll-behavior: smoothon html — native smooth scroll for anchorsoverscroll-behavior: contain— prevents scroll chaining to parent/bodyscroll-snap-typeandscroll-snap-align— native carousel without JSscrollbar-gutter: stable— reserves scrollbar space, prevents layout shift
Performance
contain: layoutisolates layout recalc —contain: strictfor maximum isolationcontent-visibility: autoskips rendering off-screen — huge paint savings on long pageswill-changehints compositor — but don't overuse, creates layers
Accessibility
prefers-reduced-motion: reduce— disable animations for vestibular disordersprefers-color-scheme—@media (prefers-color-scheme: dark)forced-colorsfor high contrast mode —@media (forced-colors: active)
Shorthand Traps
inset: 0equalstop/right/bottom/left: 0— less repetitionplace-itemsisalign-items+justify-items—place-items: centercenters bothmargin-inline,margin-blockfor logical properties — respects writing direction