[{"data":1,"prerenderedAt":2172},["ShallowReactive",2],{"page-\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fobject-fit-and-object-position\u002F":3,"content-all-pages":1608,"live-demo:object-fit-gallery":2166},{"id":4,"title":5,"body":6,"description":1587,"extension":1588,"meta":1589,"navigation":386,"path":1604,"seo":1605,"stem":1606,"__hash__":1607},"content\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fobject-fit-and-object-position\u002Findex.md","object-fit and object-position: Images That Fit Any Box",{"type":7,"value":8,"toc":1575},"minimark",[9,22,43,48,68,79,185,189,198,202,1003,1023,1030,1051,1097,1111,1115,1120,1134,1148,1160,1174,1178,1181,1361,1388,1392,1408,1426,1432,1436,1452,1456,1478,1494,1522,1539,1543,1572],[10,11,13,17,18,21],"h1",{"id":12},"object-fit-and-object-position-images-that-fit-any-box",[14,15,16],"code",{},"object-fit"," and ",[14,19,20],{},"object-position",": Images That Fit Any Box",[23,24,25,26,28,29,31,32,37,38,42],"p",{},"Responsive layouts constantly ask images to fit boxes they were not shot for: a landscape photo in a square card thumbnail, a portrait headshot in a wide banner, a product shot in a fixed-height gallery row. Without guidance the browser stretches the image to the box, distorting it. ",[14,27,16],{}," tells a replaced element how to fit its content into its box, and ",[14,30,20],{}," decides which part survives when the fit crops. This page covers each fit mode, how to choose a focal point, how to change the crop as the container changes size, and the accessibility and performance details that go with it. It belongs to ",[33,34,36],"a",{"href":35},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002F","Intrinsic Sizing Techniques"," in the ",[33,39,41],{"href":40},"\u002Fmastering-container-queries-responsive-layouts\u002F","Mastering Container Queries & Responsive Layouts"," guide.",[44,45,47],"h2",{"id":46},"why-the-box-and-the-image-are-separate","Why the box and the image are separate",[23,49,50,51,54,55,59,60,63,64,67],{},"A replaced element such as ",[14,52,53],{},"\u003Cimg>"," has two sizes. Its ",[56,57,58],"em",{},"box"," is laid out by CSS — its width, height and aspect ratio. Its ",[56,61,62],{},"content",", the image data, has an intrinsic size and ratio of its own. By default, ",[14,65,66],{},"object-fit: fill"," stretches the content to exactly fill the box, which is harmless when the ratios match and distorting when they do not.",[23,69,70,71,75,76,78],{},"That separation is useful. It means layout can decide the box — a square thumbnail, a 16:9 banner, a row of equal heights — using ",[33,72,74],{"href":73},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Faspect-ratio-for-responsive-media\u002F","aspect-ratio for responsive media"," or grid tracks, while ",[14,77,16],{}," decides how the image behaves inside it. Designers get consistent card grids regardless of the photos editors upload.",[80,81,87,88,87,92,87,96,87,104,87,115,87,123,87,128,87,133,87,136,87,144,87,148,87,151,87,154,87,157,87,160,87,163,87,166,87,169,87,174,87,177,87,180],"svg",{"viewBox":82,"role":83,"ariaLabel":84,"xmlns":85,"style":86},"0 0 720 320","img","A landscape image placed in a square box with fill, contain, cover and scale-down","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","width:100%;height:auto;max-width:720px;margin:2rem 0","\n  ",[89,90,91],"title",{},"Four fit modes for the same image and box",[93,94,95],"desc",{},"fill stretches the landscape image to the square, distorting it. contain shrinks it to fit with bands above and below. cover enlarges it to fill the square and crops the sides. scale-down behaves like contain but never enlarges a small image.",[97,98,103],"text",{"textAnchor":99,"x":100,"y":101,"style":102},"middle","360","26","text-anchor:middle;fill:currentColor;font:700 17px sans-serif","Landscape image, square box",[105,106],"rect",{"x":107,"y":108,"width":109,"height":109,"rx":110,"fill":111,"stroke":112,"strokeWidth":113,"opacity":114},"30","56","140","6","none","currentColor","1.5","0.6",[116,117],"ellipse",{"cx":118,"cy":119,"rx":120,"ry":120,"fill":121,"opacity":122},"100","126","62","#7aa2ff","0.45",[97,124,127],{"textAnchor":99,"x":118,"y":125,"style":126},"226","text-anchor:middle;fill:currentColor;font:600 12px ui-monospace,monospace","fill",[97,129,132],{"textAnchor":99,"x":118,"y":130,"style":131},"246","text-anchor:middle;fill:currentColor;font:11px sans-serif","distorted",[105,134],{"x":135,"y":108,"width":109,"height":109,"rx":110,"fill":111,"stroke":112,"strokeWidth":113,"opacity":114},"200",[105,137],{"x":138,"y":139,"width":140,"height":141,"rx":142,"fill":121,"opacity":143},"202","92","136","68","3","0.2",[116,145],{"cx":146,"cy":119,"rx":120,"ry":147,"fill":121,"opacity":122},"270","31",[97,149,150],{"textAnchor":99,"x":146,"y":125,"style":126},"contain",[97,152,153],{"textAnchor":99,"x":146,"y":130,"style":131},"bands top and bottom",[105,155],{"x":156,"y":108,"width":109,"height":109,"rx":110,"fill":111,"stroke":112,"strokeWidth":113,"opacity":114},"370",[116,158],{"cx":159,"cy":119,"rx":141,"ry":120,"fill":121,"opacity":122},"440",[97,161,162],{"textAnchor":99,"x":159,"y":125,"style":126},"cover",[97,164,165],{"textAnchor":99,"x":159,"y":130,"style":131},"sides cropped",[105,167],{"x":168,"y":108,"width":109,"height":109,"rx":110,"fill":111,"stroke":112,"strokeWidth":113,"opacity":114},"540",[116,170],{"cx":171,"cy":119,"rx":172,"ry":173,"fill":121,"opacity":122},"610","40","20",[97,175,176],{"textAnchor":99,"x":171,"y":125,"style":126},"scale-down",[97,178,179],{"textAnchor":99,"x":171,"y":130,"style":131},"never enlarged",[97,181,184],{"textAnchor":99,"x":100,"y":182,"style":183},"292","text-anchor:middle;fill:currentColor;font:12px sans-serif;opacity:0.8","none (not shown) keeps the image at its natural size and crops it to the box.",[44,186,188],{"id":187},"the-complete-implementation","The complete implementation",[23,190,191,192,194,195,197],{},"The gallery below uses ",[14,193,162],{}," with focal points for thumbnails, ",[14,196,150],{}," for product shots that must never be cropped, and changes the crop per container size. Drag the demo to see the focal point hold.",[199,200],"live-demo",{"name":201},"object-fit-gallery",[203,204,209],"pre",{"className":205,"code":206,"language":207,"meta":208,"style":208},"language-html shiki shiki-themes github-light-high-contrast github-dark-high-contrast","\u003C!doctype html>\n\u003Chtml lang=\"en\">\n\u003Chead>\n\u003Cmeta charset=\"utf-8\">\n\u003Cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\u003Ctitle>object-fit and object-position\u003C\u002Ftitle>\n\u003Cstyle>\n  body { font: 15px\u002F1.5 system-ui, sans-serif; margin: 1rem; }\n\n  .gallery {\n    display: grid;\n    grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr));\n    gap: 0.75rem;\n  }\n\n  \u002F* The box is decided by layout: full column width, square ratio. *\u002F\n  .thumb {\n    display: block;\n    width: 100%;\n    aspect-ratio: 1;\n    \u002F* The content fills the box, cropping the overflow... *\u002F\n    object-fit: cover;\n    \u002F* ...keeping this point in view. Defaults to 50% 50% if omitted. *\u002F\n    object-position: var(--focus, 50% 50%);\n    border-radius: 8px;\n    background: #e2e8f0;        \u002F* shows while loading *\u002F\n  }\n\n  \u002F* Per-image focal points supplied by the CMS as custom properties. *\u002F\n  .thumb--portrait { --focus: 50% 20%; }     \u002F* keep the face near the top *\u002F\n  .thumb--left-subject { --focus: 25% 50%; }\n\n  \u002F* Product images must never be cropped: contain, with a neutral band. *\u002F\n  .thumb--product {\n    object-fit: contain;\n    background: #f8fafc;\n    padding: 0.5rem;\n    box-sizing: border-box;\n  }\n\u003C\u002Fstyle>\n\u003C\u002Fhead>\n\u003Cbody>\n  \u003Cdiv class=\"gallery\">\n    \u003Cimg class=\"thumb thumb--portrait\" src=\"\u002Fimg\u002Fportrait.jpg\" alt=\"Climber resting on a ledge\" width=\"800\" height=\"1200\" loading=\"lazy\">\n    \u003Cimg class=\"thumb thumb--left-subject\" src=\"\u002Fimg\u002Fboat.jpg\" alt=\"Rowing boat drawn up on shingle\" width=\"1600\" height=\"900\" loading=\"lazy\">\n    \u003Cimg class=\"thumb thumb--product\" src=\"\u002Fimg\u002Fkettle.png\" alt=\"Enamel camping kettle\" width=\"1000\" height=\"1000\" loading=\"lazy\">\n  \u003C\u002Fdiv>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n","html","",[14,210,211,231,251,261,279,304,318,328,381,388,397,411,463,478,484,489,496,504,516,530,542,548,560,566,598,613,630,635,640,646,673,696,701,707,715,726,738,753,766,771,781,790,800,819,876,926,975,985,994],{"__ignoreMap":208},[212,213,216,220,224,228],"span",{"class":214,"line":215},"line",1,[212,217,219],{"class":218},"suds8","\u003C!",[212,221,223],{"class":222},"sne4z","doctype",[212,225,227],{"class":226},"s-5SL"," html",[212,229,230],{"class":218},">\n",[212,232,234,237,239,242,245,249],{"class":214,"line":233},2,[212,235,236],{"class":218},"\u003C",[212,238,207],{"class":222},[212,240,241],{"class":226}," lang",[212,243,244],{"class":218},"=",[212,246,248],{"class":247},"sT6z2","\"en\"",[212,250,230],{"class":218},[212,252,254,256,259],{"class":214,"line":253},3,[212,255,236],{"class":218},[212,257,258],{"class":222},"head",[212,260,230],{"class":218},[212,262,264,266,269,272,274,277],{"class":214,"line":263},4,[212,265,236],{"class":218},[212,267,268],{"class":222},"meta",[212,270,271],{"class":226}," charset",[212,273,244],{"class":218},[212,275,276],{"class":247},"\"utf-8\"",[212,278,230],{"class":218},[212,280,282,284,286,289,291,294,297,299,302],{"class":214,"line":281},5,[212,283,236],{"class":218},[212,285,268],{"class":222},[212,287,288],{"class":226}," name",[212,290,244],{"class":218},[212,292,293],{"class":247},"\"viewport\"",[212,295,296],{"class":226}," content",[212,298,244],{"class":218},[212,300,301],{"class":247},"\"width=device-width, initial-scale=1\"",[212,303,230],{"class":218},[212,305,307,309,311,314,316],{"class":214,"line":306},6,[212,308,236],{"class":218},[212,310,89],{"class":222},[212,312,313],{"class":218},">object-fit and object-position\u003C\u002F",[212,315,89],{"class":222},[212,317,230],{"class":218},[212,319,321,323,326],{"class":214,"line":320},7,[212,322,236],{"class":218},[212,324,325],{"class":222},"style",[212,327,230],{"class":218},[212,329,331,334,337,340,343,346,350,353,355,358,361,364,367,370,372,375,378],{"class":214,"line":330},8,[212,332,333],{"class":222},"  body",[212,335,336],{"class":218}," { ",[212,338,339],{"class":226},"font",[212,341,342],{"class":218},": ",[212,344,345],{"class":226},"15",[212,347,349],{"class":348},"sHUrx","px",[212,351,352],{"class":218},"\u002F",[212,354,113],{"class":226},[212,356,357],{"class":226}," system-ui",[212,359,360],{"class":218},", ",[212,362,363],{"class":226},"sans-serif",[212,365,366],{"class":218},"; ",[212,368,369],{"class":226},"margin",[212,371,342],{"class":218},[212,373,374],{"class":226},"1",[212,376,377],{"class":348},"rem",[212,379,380],{"class":218},"; }\n",[212,382,384],{"class":214,"line":383},9,[212,385,387],{"emptyLinePlaceholder":386},true,"\n",[212,389,391,394],{"class":214,"line":390},10,[212,392,393],{"class":226},"  .gallery",[212,395,396],{"class":218}," {\n",[212,398,400,403,405,408],{"class":214,"line":399},11,[212,401,402],{"class":226},"    display",[212,404,342],{"class":218},[212,406,407],{"class":226},"grid",[212,409,410],{"class":218},";\n",[212,412,414,417,419,422,425,428,430,433,435,438,440,442,445,447,450,452,455,457,460],{"class":214,"line":413},12,[212,415,416],{"class":226},"    grid-template-columns",[212,418,342],{"class":218},[212,420,421],{"class":226},"repeat",[212,423,424],{"class":218},"(",[212,426,427],{"class":226},"auto-fill",[212,429,360],{"class":218},[212,431,432],{"class":226},"minmax",[212,434,424],{"class":218},[212,436,437],{"class":226},"min",[212,439,424],{"class":218},[212,441,118],{"class":226},[212,443,444],{"class":348},"%",[212,446,360],{"class":218},[212,448,449],{"class":226},"12",[212,451,377],{"class":348},[212,453,454],{"class":218},"), ",[212,456,374],{"class":226},[212,458,459],{"class":348},"fr",[212,461,462],{"class":218},"));\n",[212,464,466,469,471,474,476],{"class":214,"line":465},13,[212,467,468],{"class":226},"    gap",[212,470,342],{"class":218},[212,472,473],{"class":226},"0.75",[212,475,377],{"class":348},[212,477,410],{"class":218},[212,479,481],{"class":214,"line":480},14,[212,482,483],{"class":218},"  }\n",[212,485,487],{"class":214,"line":486},15,[212,488,387],{"emptyLinePlaceholder":386},[212,490,492],{"class":214,"line":491},16,[212,493,495],{"class":494},"sLBg1","  \u002F* The box is decided by layout: full column width, square ratio. *\u002F\n",[212,497,499,502],{"class":214,"line":498},17,[212,500,501],{"class":226},"  .thumb",[212,503,396],{"class":218},[212,505,507,509,511,514],{"class":214,"line":506},18,[212,508,402],{"class":226},[212,510,342],{"class":218},[212,512,513],{"class":226},"block",[212,515,410],{"class":218},[212,517,519,522,524,526,528],{"class":214,"line":518},19,[212,520,521],{"class":226},"    width",[212,523,342],{"class":218},[212,525,118],{"class":226},[212,527,444],{"class":348},[212,529,410],{"class":218},[212,531,533,536,538,540],{"class":214,"line":532},20,[212,534,535],{"class":226},"    aspect-ratio",[212,537,342],{"class":218},[212,539,374],{"class":226},[212,541,410],{"class":218},[212,543,545],{"class":214,"line":544},21,[212,546,547],{"class":494},"    \u002F* The content fills the box, cropping the overflow... *\u002F\n",[212,549,551,554,556,558],{"class":214,"line":550},22,[212,552,553],{"class":226},"    object-fit",[212,555,342],{"class":218},[212,557,162],{"class":226},[212,559,410],{"class":218},[212,561,563],{"class":214,"line":562},23,[212,564,565],{"class":494},"    \u002F* ...keeping this point in view. Defaults to 50% 50% if omitted. *\u002F\n",[212,567,569,572,574,577,579,583,585,588,590,593,595],{"class":214,"line":568},24,[212,570,571],{"class":226},"    object-position",[212,573,342],{"class":218},[212,575,576],{"class":226},"var",[212,578,424],{"class":218},[212,580,582],{"class":581},"soyes","--focus",[212,584,360],{"class":218},[212,586,587],{"class":226},"50",[212,589,444],{"class":348},[212,591,592],{"class":226}," 50",[212,594,444],{"class":348},[212,596,597],{"class":218},");\n",[212,599,601,604,606,609,611],{"class":214,"line":600},25,[212,602,603],{"class":226},"    border-radius",[212,605,342],{"class":218},[212,607,608],{"class":226},"8",[212,610,349],{"class":348},[212,612,410],{"class":218},[212,614,616,619,621,624,627],{"class":214,"line":615},26,[212,617,618],{"class":226},"    background",[212,620,342],{"class":218},[212,622,623],{"class":226},"#e2e8f0",[212,625,626],{"class":218},";        ",[212,628,629],{"class":494},"\u002F* shows while loading *\u002F\n",[212,631,633],{"class":214,"line":632},27,[212,634,483],{"class":218},[212,636,638],{"class":214,"line":637},28,[212,639,387],{"emptyLinePlaceholder":386},[212,641,643],{"class":214,"line":642},29,[212,644,645],{"class":494},"  \u002F* Per-image focal points supplied by the CMS as custom properties. *\u002F\n",[212,647,649,652,654,656,658,660,662,665,667,670],{"class":214,"line":648},30,[212,650,651],{"class":226},"  .thumb--portrait",[212,653,336],{"class":218},[212,655,582],{"class":581},[212,657,342],{"class":218},[212,659,587],{"class":226},[212,661,444],{"class":348},[212,663,664],{"class":226}," 20",[212,666,444],{"class":348},[212,668,669],{"class":218},"; }     ",[212,671,672],{"class":494},"\u002F* keep the face near the top *\u002F\n",[212,674,676,679,681,683,685,688,690,692,694],{"class":214,"line":675},31,[212,677,678],{"class":226},"  .thumb--left-subject",[212,680,336],{"class":218},[212,682,582],{"class":581},[212,684,342],{"class":218},[212,686,687],{"class":226},"25",[212,689,444],{"class":348},[212,691,592],{"class":226},[212,693,444],{"class":348},[212,695,380],{"class":218},[212,697,699],{"class":214,"line":698},32,[212,700,387],{"emptyLinePlaceholder":386},[212,702,704],{"class":214,"line":703},33,[212,705,706],{"class":494},"  \u002F* Product images must never be cropped: contain, with a neutral band. *\u002F\n",[212,708,710,713],{"class":214,"line":709},34,[212,711,712],{"class":226},"  .thumb--product",[212,714,396],{"class":218},[212,716,718,720,722,724],{"class":214,"line":717},35,[212,719,553],{"class":226},[212,721,342],{"class":218},[212,723,150],{"class":226},[212,725,410],{"class":218},[212,727,729,731,733,736],{"class":214,"line":728},36,[212,730,618],{"class":226},[212,732,342],{"class":218},[212,734,735],{"class":226},"#f8fafc",[212,737,410],{"class":218},[212,739,741,744,746,749,751],{"class":214,"line":740},37,[212,742,743],{"class":226},"    padding",[212,745,342],{"class":218},[212,747,748],{"class":226},"0.5",[212,750,377],{"class":348},[212,752,410],{"class":218},[212,754,756,759,761,764],{"class":214,"line":755},38,[212,757,758],{"class":226},"    box-sizing",[212,760,342],{"class":218},[212,762,763],{"class":226},"border-box",[212,765,410],{"class":218},[212,767,769],{"class":214,"line":768},39,[212,770,483],{"class":218},[212,772,774,777,779],{"class":214,"line":773},40,[212,775,776],{"class":218},"\u003C\u002F",[212,778,325],{"class":222},[212,780,230],{"class":218},[212,782,784,786,788],{"class":214,"line":783},41,[212,785,776],{"class":218},[212,787,258],{"class":222},[212,789,230],{"class":218},[212,791,793,795,798],{"class":214,"line":792},42,[212,794,236],{"class":218},[212,796,797],{"class":222},"body",[212,799,230],{"class":218},[212,801,803,806,809,812,814,817],{"class":214,"line":802},43,[212,804,805],{"class":218},"  \u003C",[212,807,808],{"class":222},"div",[212,810,811],{"class":226}," class",[212,813,244],{"class":218},[212,815,816],{"class":247},"\"gallery\"",[212,818,230],{"class":218},[212,820,822,825,827,829,831,834,837,839,842,845,847,850,853,855,858,861,863,866,869,871,874],{"class":214,"line":821},44,[212,823,824],{"class":218},"    \u003C",[212,826,83],{"class":222},[212,828,811],{"class":226},[212,830,244],{"class":218},[212,832,833],{"class":247},"\"thumb thumb--portrait\"",[212,835,836],{"class":226}," src",[212,838,244],{"class":218},[212,840,841],{"class":247},"\"\u002Fimg\u002Fportrait.jpg\"",[212,843,844],{"class":226}," alt",[212,846,244],{"class":218},[212,848,849],{"class":247},"\"Climber resting on a ledge\"",[212,851,852],{"class":226}," width",[212,854,244],{"class":218},[212,856,857],{"class":247},"\"800\"",[212,859,860],{"class":226}," height",[212,862,244],{"class":218},[212,864,865],{"class":247},"\"1200\"",[212,867,868],{"class":226}," loading",[212,870,244],{"class":218},[212,872,873],{"class":247},"\"lazy\"",[212,875,230],{"class":218},[212,877,879,881,883,885,887,890,892,894,897,899,901,904,906,908,911,913,915,918,920,922,924],{"class":214,"line":878},45,[212,880,824],{"class":218},[212,882,83],{"class":222},[212,884,811],{"class":226},[212,886,244],{"class":218},[212,888,889],{"class":247},"\"thumb thumb--left-subject\"",[212,891,836],{"class":226},[212,893,244],{"class":218},[212,895,896],{"class":247},"\"\u002Fimg\u002Fboat.jpg\"",[212,898,844],{"class":226},[212,900,244],{"class":218},[212,902,903],{"class":247},"\"Rowing boat drawn up on shingle\"",[212,905,852],{"class":226},[212,907,244],{"class":218},[212,909,910],{"class":247},"\"1600\"",[212,912,860],{"class":226},[212,914,244],{"class":218},[212,916,917],{"class":247},"\"900\"",[212,919,868],{"class":226},[212,921,244],{"class":218},[212,923,873],{"class":247},[212,925,230],{"class":218},[212,927,929,931,933,935,937,940,942,944,947,949,951,954,956,958,961,963,965,967,969,971,973],{"class":214,"line":928},46,[212,930,824],{"class":218},[212,932,83],{"class":222},[212,934,811],{"class":226},[212,936,244],{"class":218},[212,938,939],{"class":247},"\"thumb thumb--product\"",[212,941,836],{"class":226},[212,943,244],{"class":218},[212,945,946],{"class":247},"\"\u002Fimg\u002Fkettle.png\"",[212,948,844],{"class":226},[212,950,244],{"class":218},[212,952,953],{"class":247},"\"Enamel camping kettle\"",[212,955,852],{"class":226},[212,957,244],{"class":218},[212,959,960],{"class":247},"\"1000\"",[212,962,860],{"class":226},[212,964,244],{"class":218},[212,966,960],{"class":247},[212,968,868],{"class":226},[212,970,244],{"class":218},[212,972,873],{"class":247},[212,974,230],{"class":218},[212,976,978,981,983],{"class":214,"line":977},47,[212,979,980],{"class":218},"  \u003C\u002F",[212,982,808],{"class":222},[212,984,230],{"class":218},[212,986,988,990,992],{"class":214,"line":987},48,[212,989,776],{"class":218},[212,991,797],{"class":222},[212,993,230],{"class":218},[212,995,997,999,1001],{"class":214,"line":996},49,[212,998,776],{"class":218},[212,1000,207],{"class":222},[212,1002,230],{"class":218},[23,1004,1005,1006,17,1009,1012,1013,1015,1016,1019,1020,1022],{},"The ",[14,1007,1008],{},"width",[14,1010,1011],{},"height"," attributes on each ",[14,1014,53],{}," are not decoration. They give the browser the image's intrinsic ratio before it loads, and combined with the CSS ",[14,1017,1018],{},"aspect-ratio"," they guarantee the box never changes size when the image arrives, which avoids layout shift. The CSS then overrides the attribute-derived ratio with the square the design wants, and ",[14,1021,16],{}," fits the image into it.",[44,1024,1026,1027,1029],{"id":1025},"the-key-technique-object-position-is-a-focal-point","The key technique: ",[14,1028,20],{}," is a focal point",[23,1031,1032,1033,1035,1036,1038,1039,1042,1043,1046,1047,1050],{},"With ",[14,1034,162],{},", the image is scaled until it covers the box on both axes, so it overflows on one axis. ",[14,1037,20],{}," aligns the image within the box along that overflowing axis, exactly as ",[14,1040,1041],{},"background-position"," does for backgrounds. Percentages are the most useful form, because they describe a point ",[56,1044,1045],{},"in the image"," that is aligned with the same relative point ",[56,1048,1049],{},"in the box",".",[80,1052,87,1055,87,1058,87,1061,87,1064,87,1069,87,1075,87,1082,87,1086,87,1089,87,1091,87,1094],{"viewBox":1053,"role":83,"ariaLabel":1054,"xmlns":85,"style":86},"0 0 720 280","A tall portrait covering a wide box with object-position 50% 50% cropping the face, and 50% 20% keeping it",[89,1056,1057],{},"Choosing what survives a crop",[93,1059,1060],{},"A tall image with a face near the top is placed in a wide box with object-fit cover. With the default 50% 50% position the middle of the image is shown and the face is cut off. With 50% 20% the upper part is shown and the face stays in frame.",[97,1062,1063],{"textAnchor":99,"x":100,"y":101,"style":102},"Tall portrait in a wide box, cover",[1065,1066],"path",{"d":1067,"fill":121,"opacity":1068},"M110 40 H250 V260 H110 Z","0.14",[1070,1071],"circle",{"cx":1072,"cy":1073,"r":173,"fill":112,"opacity":1074},"180","80","0.4",[105,1076],{"x":1077,"y":1078,"width":1079,"height":1080,"rx":110,"fill":111,"stroke":112,"strokeWidth":1081},"60","120","240","90","2.5",[97,1083,1085],{"textAnchor":99,"x":1072,"y":1084,"style":126},"250","50% 50%: face cropped",[1065,1087],{"d":1088,"fill":121,"opacity":1068},"M470 40 H610 V260 H470 Z",[1070,1090],{"cx":168,"cy":1073,"r":173,"fill":112,"opacity":1074},[105,1092],{"x":1093,"y":587,"width":1079,"height":1080,"rx":110,"fill":111,"stroke":112,"strokeWidth":1081},"420",[97,1095,1096],{"textAnchor":99,"x":168,"y":1084,"style":126},"50% 20%: face kept",[23,1098,1099,1100,1102,1103,1106,1107,1110],{},"Because the position is a property of each image's content, the natural place to store it is alongside the image: a CMS field for the focal point, output as a custom property in a ",[14,1101,325],{}," attribute (",[14,1104,1105],{},"style=\"--focus: 50% 20%\"","). The stylesheet reads ",[14,1108,1109],{},"var(--focus, 50% 50%)",", so images without a focal point use the centre.",[44,1112,1114],{"id":1113},"video-canvas-and-embeds","Video, canvas and embeds",[23,1116,1117,1119],{},[14,1118,16],{}," is not only for photographs. Any replaced element supports it, and the same reasoning applies.",[23,1121,1122,1126,1127,1130,1131,1133],{},[1123,1124,1125],"strong",{},"Video."," A background or hero video shot at 16:9 placed in a tall mobile hero will letterbox by default, with bars above and below. ",[14,1128,1129],{},"object-fit: cover"," fills the box and crops the sides, which is usually what a decorative video wants; ",[14,1132,20],{}," chooses which part of the frame stays visible. Poster images use the same fit, so the still frame and the playing video match exactly. Decorative autoplaying video also falls under WCAG 2.2.2 Pause, Stop, Hide if it runs longer than five seconds, so provide a pause control or stop it for reduced-motion users.",[23,1135,1136,1139,1140,1143,1144,1147],{},[1123,1137,1138],{},"Canvas and generated images."," A ",[14,1141,1142],{},"\u003Ccanvas>"," whose internal resolution differs from its display box can use ",[14,1145,1146],{},"object-fit: contain"," to preserve its drawing's ratio without distortion when the layout resizes it.",[23,1149,1150,1153,1154,1156,1157,1159],{},[1123,1151,1152],{},"Iframes and embeds."," Embedded content is typically sized by its own document, and ",[14,1155,16],{}," generally has no useful effect on an iframe's internal layout. For responsive embeds, size the iframe box with ",[14,1158,1018],{}," and let the embedded page handle its own fit.",[23,1161,1162,1165,1166,1168,1169,17,1171,1173],{},[1123,1163,1164],{},"Scale-down for icons and logos."," ",[14,1167,176],{}," picks whichever of ",[14,1170,111],{},[14,1172,150],{}," gives the smaller result, so small logos are never enlarged into blurry blobs while large ones still shrink to fit. It is the right choice for partner-logo grids and user-uploaded avatars of unknown size.",[44,1175,1177],{"id":1176},"art-direction-across-container-sizes","Art direction across container sizes",[23,1179,1180],{},"Sometimes a single focal point is not enough. A wide banner crop of a group photo might show everyone, while the square thumbnail of the same photo should show only the central figure. Container queries can change both the box and the focal point, so a component can choose a different crop depending on the space it has.",[203,1182,1186],{"className":1183,"code":1184,"language":1185,"meta":208,"style":208},"language-css shiki shiki-themes github-light-high-contrast github-dark-high-contrast",".hero-slot { container-type: inline-size; }\n\n.hero-img {\n  width: 100%;\n  aspect-ratio: 4 \u002F 3;               \u002F* narrow: fairly tall crop *\u002F\n  object-fit: cover;\n  object-position: var(--focus-narrow, 50% 40%);\n}\n\n@container (width > 40rem) {\n  .hero-img {\n    aspect-ratio: 21 \u002F 9;             \u002F* wide: cinematic crop *\u002F\n    object-position: var(--focus-wide, 50% 50%);\n  }\n}\n","css",[14,1187,1188,1201,1205,1212,1225,1246,1257,1284,1289,1293,1301,1308,1328,1353,1357],{"__ignoreMap":208},[212,1189,1190,1193,1195,1198],{"class":214,"line":215},[212,1191,1192],{"class":226},".hero-slot",[212,1194,336],{"class":218},[212,1196,1197],{"class":226},"container-type",[212,1199,1200],{"class":218},": inline-size; }\n",[212,1202,1203],{"class":214,"line":233},[212,1204,387],{"emptyLinePlaceholder":386},[212,1206,1207,1210],{"class":214,"line":253},[212,1208,1209],{"class":226},".hero-img",[212,1211,396],{"class":218},[212,1213,1214,1217,1219,1221,1223],{"class":214,"line":263},[212,1215,1216],{"class":226},"  width",[212,1218,342],{"class":218},[212,1220,118],{"class":226},[212,1222,444],{"class":348},[212,1224,410],{"class":218},[212,1226,1227,1230,1232,1235,1238,1240,1243],{"class":214,"line":281},[212,1228,1229],{"class":226},"  aspect-ratio",[212,1231,342],{"class":218},[212,1233,1234],{"class":226},"4",[212,1236,1237],{"class":218}," \u002F ",[212,1239,142],{"class":226},[212,1241,1242],{"class":218},";               ",[212,1244,1245],{"class":494},"\u002F* narrow: fairly tall crop *\u002F\n",[212,1247,1248,1251,1253,1255],{"class":214,"line":306},[212,1249,1250],{"class":226},"  object-fit",[212,1252,342],{"class":218},[212,1254,162],{"class":226},[212,1256,410],{"class":218},[212,1258,1259,1262,1264,1266,1268,1271,1273,1275,1277,1280,1282],{"class":214,"line":320},[212,1260,1261],{"class":226},"  object-position",[212,1263,342],{"class":218},[212,1265,576],{"class":226},[212,1267,424],{"class":218},[212,1269,1270],{"class":581},"--focus-narrow",[212,1272,360],{"class":218},[212,1274,587],{"class":226},[212,1276,444],{"class":348},[212,1278,1279],{"class":226}," 40",[212,1281,444],{"class":348},[212,1283,597],{"class":218},[212,1285,1286],{"class":214,"line":330},[212,1287,1288],{"class":218},"}\n",[212,1290,1291],{"class":214,"line":383},[212,1292,387],{"emptyLinePlaceholder":386},[212,1294,1295,1298],{"class":214,"line":390},[212,1296,1297],{"class":348},"@container",[212,1299,1300],{"class":218}," (width > 40rem) {\n",[212,1302,1303,1306],{"class":214,"line":399},[212,1304,1305],{"class":226},"  .hero-img",[212,1307,396],{"class":218},[212,1309,1310,1312,1314,1317,1319,1322,1325],{"class":214,"line":413},[212,1311,535],{"class":226},[212,1313,342],{"class":218},[212,1315,1316],{"class":226},"21",[212,1318,1237],{"class":218},[212,1320,1321],{"class":226},"9",[212,1323,1324],{"class":218},";             ",[212,1326,1327],{"class":494},"\u002F* wide: cinematic crop *\u002F\n",[212,1329,1330,1332,1334,1336,1338,1341,1343,1345,1347,1349,1351],{"class":214,"line":465},[212,1331,571],{"class":226},[212,1333,342],{"class":218},[212,1335,576],{"class":226},[212,1337,424],{"class":218},[212,1339,1340],{"class":581},"--focus-wide",[212,1342,360],{"class":218},[212,1344,587],{"class":226},[212,1346,444],{"class":348},[212,1348,592],{"class":226},[212,1350,444],{"class":348},[212,1352,597],{"class":218},[212,1354,1355],{"class":214,"line":480},[212,1356,483],{"class":218},[212,1358,1359],{"class":214,"line":486},[212,1360,1288],{"class":218},[23,1362,1363,1364,1367,1368,1371,1372,1375,1376,1379,1380,1382,1383,1387],{},"For crops so different that one image cannot serve both, use ",[14,1365,1366],{},"\u003Cpicture>"," with ",[14,1369,1370],{},"\u003Csource media>"," to swap files; ",[14,1373,1374],{},"media"," on ",[14,1377,1378],{},"\u003Csource>"," responds to the viewport, not the container, so it suits page-level heroes rather than reusable components. Animating between crops — transitioning ",[14,1381,20],{}," on hover to pan across an image — is possible and cheap on small thumbnails; see ",[33,1384,1386],{"href":1385},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fsmooth-hover-effects-without-javascript\u002F","Smooth Hover Effects Without JavaScript"," for the hover patterns and keep such motion out of reduced-motion experiences.",[44,1389,1391],{"id":1390},"accessibility-and-performance-notes","Accessibility and performance notes",[23,1393,1394,1397,1398,1400,1401,1403,1404,1407],{},[1123,1395,1396],{},"Cropping hides information."," If the cropped part of an image carries meaning — text in a screenshot, the relevant part of a chart — ",[14,1399,162],{}," can remove it. Use ",[14,1402,150],{}," for informational images, and make sure the ",[14,1405,1406],{},"alt"," text describes the image as it matters, not just what survives the crop.",[23,1409,1410,1165,1413,1415,1416,17,1419,1422,1423,1425],{},[1123,1411,1412],{},"Serve appropriately sized files.",[14,1414,16],{}," crops visually but still downloads the whole image. With ",[14,1417,1418],{},"srcset",[14,1420,1421],{},"sizes",", the browser can pick a file close to the displayed size; for square thumbnails of landscape photos, the chosen file is decided by the box ",[56,1424,1008],{},", so a 300-pixel-wide thumbnail downloads a 300-pixel-wide landscape file and crops its sides.",[23,1427,1428,1431],{},[1123,1429,1430],{},"Reserve the box."," Always give images a width and height or an aspect ratio so the page does not shift as they load.",[44,1433,1435],{"id":1434},"browser-support","Browser support",[23,1437,1438,17,1440,1442,1443,360,1445,1448,1449,1451],{},[14,1439,16],{},[14,1441,20],{}," are supported in all current engines and have been for many years, for ",[14,1444,53],{},[14,1446,1447],{},"\u003Cvideo>"," and other replaced elements. ",[14,1450,1018],{}," is supported in Chrome and Edge 88+, Firefox 89+ and Safari 15+. Container queries, used for art direction, are supported in Chrome and Edge 105+, Firefox 110+ and Safari 16+.",[44,1453,1455],{"id":1454},"faq","FAQ",[23,1457,1458,1466,1468,1469,1471,1472,1474,1475,1477],{},[1123,1459,1460,1461,17,1463,1465],{},"What is the difference between ",[14,1462,1129],{},[14,1464,150],{},"?",[14,1467,162],{}," scales the image to fill the whole box, cropping whatever overflows. ",[14,1470,150],{}," scales it to fit entirely inside the box, leaving empty space on two sides if the ratios differ. ",[14,1473,162],{}," guarantees no gaps; ",[14,1476,150],{}," guarantees nothing is cut off.",[23,1479,1480,1483,1484,1486,1487,1490,1491,1493],{},[1123,1481,1482],{},"How do I keep a person's face in frame when an image is cropped?","\nSet ",[14,1485,20],{}," to the face's location as percentages, such as ",[14,1488,1489],{},"object-position: 40% 25%",". When ",[14,1492,162],{}," crops the image, it keeps that point as close to the same relative position as the crop allows, so the focal point stays visible.",[23,1495,1496,1502,1503,1505,1506,360,1508,1511,1512,1515,1516,1518,1519,1521],{},[1123,1497,1498,1499,1501],{},"Does ",[14,1500,16],{}," work on background images?","\nNo. ",[14,1504,16],{}," applies to replaced elements such as ",[14,1507,83],{},[14,1509,1510],{},"video",", canvas-like embeds and iframes. The equivalent for background images is ",[14,1513,1514],{},"background-size: cover"," or ",[14,1517,150],{},", with ",[14,1520,1041],{}," for the focal point.",[23,1523,1524,1529,1530,1532,1533,1535,1536,1538],{},[1123,1525,1526,1527,1465],{},"Why is my image still distorted with ",[14,1528,1129],{},"\nUsually because the ",[14,1531,83],{}," element itself has no definite box to fit into, so it takes the image's own ratio and ",[14,1534,16],{}," has nothing to do. Give the element both a width and a height, or a width and an ",[14,1537,1018],{},", so the box ratio differs from the image ratio.",[44,1540,1542],{"id":1541},"related","Related",[1544,1545,1546,1552,1558,1565],"ul",{},[1547,1548,1549,1551],"li",{},[33,1550,36],{"href":35}," — the parent guide.",[1547,1553,1554,1557],{},[33,1555,1556],{"href":73},"Aspect Ratio for Responsive Media"," — deciding the box the image fits into.",[1547,1559,1560,1564],{},[33,1561,1563],{"href":1562},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fbuilding-responsive-cards-with-container-queries\u002F","Building Responsive Cards With Container Queries"," — card thumbnails in context.",[1547,1566,1567,1571],{},[33,1568,1570],{"href":1569},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations\u002Fclip-path-reveal-animations\u002F","Clip-Path Reveal Animations"," — revealing cropped images with motion.",[325,1573,1574],{},"html pre.shiki code .suds8, html code.shiki .suds8{--shiki-default:#0E1116;--shiki-dark:#F0F3F6}html pre.shiki code .sne4z, html code.shiki .sne4z{--shiki-default:#024C1A;--shiki-dark:#72F088}html pre.shiki code .s-5SL, html code.shiki .s-5SL{--shiki-default:#023B95;--shiki-dark:#91CBFF}html pre.shiki code .sT6z2, html code.shiki .sT6z2{--shiki-default:#032563;--shiki-dark:#ADDCFF}html pre.shiki code .sHUrx, html code.shiki .sHUrx{--shiki-default:#A0111F;--shiki-dark:#FF9492}html pre.shiki code .sLBg1, html code.shiki .sLBg1{--shiki-default:#66707B;--shiki-dark:#BDC4CC}html pre.shiki code .soyes, html code.shiki .soyes{--shiki-default:#702C00;--shiki-dark:#FFB757}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":208,"searchDepth":233,"depth":233,"links":1576},[1577,1578,1579,1581,1582,1583,1584,1585,1586],{"id":46,"depth":233,"text":47},{"id":187,"depth":233,"text":188},{"id":1025,"depth":233,"text":1580},"The key technique: object-position is a focal point",{"id":1113,"depth":233,"text":1114},{"id":1176,"depth":233,"text":1177},{"id":1390,"depth":233,"text":1391},{"id":1434,"depth":233,"text":1435},{"id":1454,"depth":233,"text":1455},{"id":1541,"depth":233,"text":1542},"Fit images and video into fixed-ratio boxes without distortion: cover, contain, scale-down, focal points with object-position, and art direction by container.","md",{"pageTitle":1590,"datePublished":1591,"dateModified":1591,"faq":1592},"object-fit and object-position in Practice","2026-09-18",[1593,1596,1598,1601],{"q":1594,"a":1595},"What is the difference between object-fit: cover and contain?","cover scales the image to fill the whole box, cropping whatever overflows. contain scales it to fit entirely inside the box, leaving empty space on two sides if the ratios differ. cover guarantees no gaps; contain guarantees nothing is cut off.",{"q":1482,"a":1597},"Set object-position to the face's location as percentages, such as object-position: 40% 25%. When cover crops the image, it keeps that point as close to the same relative position as the crop allows, so the focal point stays visible.",{"q":1599,"a":1600},"Does object-fit work on background images?","No. object-fit applies to replaced elements such as img, video, canvas-like embeds and iframes. The equivalent for background images is background-size: cover or contain, with background-position for the focal point.",{"q":1602,"a":1603},"Why is my image still distorted with object-fit: cover?","Usually because the img element itself has no definite box to fit into, so it takes the image's own ratio and object-fit has nothing to do. Give the element both a width and a height, or a width and an aspect-ratio, so the box ratio differs from the image ratio.","\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fobject-fit-and-object-position",{"title":5,"description":1587},"mastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fobject-fit-and-object-position\u002Findex","KNMGqneR2GB-2KRyBlJJPyd25vXZRTo5968JL2iuq-4",[1609,1612,1615,1618,1621,1624,1627,1630,1633,1636,1639,1642,1645,1648,1651,1654,1657,1660,1663,1666,1669,1672,1675,1678,1681,1684,1687,1690,1693,1696,1699,1702,1705,1708,1711,1714,1717,1720,1723,1726,1729,1732,1735,1738,1741,1744,1747,1750,1753,1756,1759,1762,1765,1768,1771,1774,1777,1780,1783,1786,1789,1792,1795,1798,1801,1804,1807,1810,1813,1816,1819,1822,1825,1828,1831,1834,1837,1840,1843,1846,1849,1852,1855,1858,1861,1864,1867,1870,1873,1876,1879,1882,1885,1888,1890,1893,1896,1899,1902,1905,1908,1911,1914,1917,1920,1923,1926,1929,1932,1935,1938,1941,1944,1947,1950,1953,1956,1959,1962,1965,1968,1971,1974,1977,1980,1983,1986,1989,1992,1995,1998,2001,2004,2007,2010,2013,2016,2019,2022,2025,2028,2030,2033,2036,2039,2042,2045,2046,2049,2052,2055,2058,2061,2064,2067,2070,2073,2076,2079,2082,2085,2088,2091,2094,2097,2100,2103,2106,2109,2112,2115,2118,2121,2124,2127,2130,2133,2136,2139,2142,2145,2148,2151,2154,2157,2160,2163],{"path":1610,"title":1611},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fcreating-accessible-focus-indicators","Creating Accessible Focus Indicators: Building a Ring That Survives Any Background",{"path":1613,"title":1614},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fflashing-content-and-seizure-thresholds","Flashing Content and Seizure Thresholds",{"path":1616,"title":1617},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fforced-colors-mode-and-animations","Forced Colors Mode and Animations",{"path":1619,"title":1620},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations","Accessibility in CSS Animations: Patterns, Specs & Best Practices",{"path":1622,"title":1623},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fpause-controls-for-looping-animations","Pause Controls for Looping CSS Animations: Meeting WCAG 2.2.2",{"path":1625,"title":1626},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fprefers-reduced-motion-recipes","prefers-reduced-motion Recipes: A Reduction for Every Common Effect",{"path":1628,"title":1629},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Freducing-motion-preferences-in-css","Reducing Motion Preferences in CSS: How the Setting Becomes a Media Feature",{"path":1631,"title":1632},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Ftarget-size-and-pointer-accessibility","Target Size and Pointer Accessibility: Meeting 2.5.8 Without Redesigning",{"path":1634,"title":1635},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fvestibular-safe-animation-patterns","Vestibular-Safe Animation Patterns: Why Some Motion Makes People Sick",{"path":1637,"title":1638},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fwcag-motion-success-criteria","WCAG Motion Success Criteria: What Each One Actually Requires",{"path":1640,"title":1641},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations\u002Fanimated-gradient-borders-with-property","Animated Gradient Borders With @property: A Spinning Highlight Without Extra Elements",{"path":1643,"title":1644},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations\u002Fclip-path-reveal-animations","Clip-Path Reveal Animations: Wipes, Irises and Corners Without Extra Markup",{"path":1646,"title":1647},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations","Clip-Path & Mask Animations: Animating Visibility Instead of Position",{"path":1649,"title":1650},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations\u002Fmask-image-fade-edges","Fading Edges With mask-image: Soft Boundaries That Work on Any Background",{"path":1652,"title":1653},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations\u002Fmorphing-shapes-with-clip-path-polygon","Morphing Shapes With clip-path: polygon(): Point-Matched Transitions",{"path":1655,"title":1656},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fanimating-gradients","Animating CSS Gradients: Smooth Colour Motion Without Jumps",{"path":1658,"title":1659},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fcolor-mix-hover-states","Hover and Active States With color-mix(): One Token, Every Shade",{"path":1661,"title":1662},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions","Color & Theme Transitions: Colour as Part of the Motion System",{"path":1664,"title":1665},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Flight-dark-function-for-themes","Light and Dark Themes With light-dark(): One Declaration per Colour",{"path":1667,"title":1668},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fsmooth-theme-switching-transitions","Smooth Theme Switching: Crossfades, Circular Reveals and No Flash",{"path":1670,"title":1671},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fcontainer-query-hover-affordances","Container Query Hover Affordances: When Narrow Means Persistent, Not Hidden",{"path":1673,"title":1674},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion","Container-Aware Motion: Animation Sized by the Space a Component Actually Has",{"path":1676,"title":1677},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Flayout-change-animations-at-container-breakpoints","Animating Changes at Container Breakpoints",{"path":1679,"title":1680},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fmotion-driven-by-container-style-queries","Motion Driven by Container Style Queries",{"path":1682,"title":1683},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fmotion-that-scales-with-container-size","Motion That Scales with Container Size: cqi, cqb, and Derived Durations",{"path":1685,"title":1686},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fsuppressing-motion-in-small-containers","Suppressing Motion in Small Containers: Deliberately Animating Nothing",{"path":1688,"title":1689},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fcontrolling-css-animations-from-javascript","Controlling CSS Animations From JavaScript",{"path":1691,"title":1692},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api","CSS Animation vs the Web Animations API: A Decision Guide",{"path":1694,"title":1695},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fwaapi-vs-css-for-interruptible-ui","Interruptible UI: CSS Transitions vs WAAPI",{"path":1697,"title":1698},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fwhen-to-use-javascript-animation","When to Use JavaScript Instead of CSS for Animation",{"path":1700,"title":1701},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fanimating-custom-properties-with-at-property","Animating Custom Properties with @property: Typed Variables That Interpolate",{"path":1703,"title":1704},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fcustom-property-fallbacks-and-invalid-values","Custom Property Fallbacks and Invalid Values",{"path":1706,"title":1707},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Ffluid-spacing-tokens-driving-transition-durations","Fluid Spacing Tokens That Drive Transition Durations",{"path":1709,"title":1710},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture","CSS Custom Properties Architecture: Scalable Design Systems & Dynamic UI",{"path":1712,"title":1713},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fregistered-properties-and-type-safety","Registered Properties and Type Safety: @property as a Contract for Design Tokens",{"path":1715,"title":1716},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fscoping-custom-properties-to-components","Scoping Custom Properties to Components",{"path":1718,"title":1719},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fcss-transition-timing-functions","CSS Transition Timing Functions: ease, cubic-bezier(), steps() and linear()",{"path":1721,"title":1722},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals","CSS Transition Fundamentals: Architecture, Performance & Patterns",{"path":1724,"title":1725},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Finterrupted-and-reversing-transitions","Interrupted and Reversing Transitions: What Happens Mid-Flight",{"path":1727,"title":1728},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fstarting-style-entry-animations","@starting-style: Animating an Element's Very First Style Change",{"path":1730,"title":1731},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransition-delay-choreography","Choreographing Motion With transition-delay",{"path":1733,"title":1734},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransition-shorthand-and-multiple-properties","The transition Shorthand and Multiple Properties",{"path":1736,"title":1737},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransitioning-display-with-allow-discrete","Transitioning display with transition-behavior: allow-discrete and @starting-style",{"path":1739,"title":1740},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fanimating-dialog-open-and-close","Animating \u003Cdialog> Open and Close: Both Directions, No Library",{"path":1742,"title":1743},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fbackdrop-animations","Animating ::backdrop: Fades and Blurs Behind Dialogs and Popovers",{"path":1745,"title":1746},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations","Dialog & Popover Animations: Motion for the Top Layer",{"path":1748,"title":1749},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Finterpolate-size-for-height-auto-animation","Animating to height: auto With interpolate-size and calc-size()",{"path":1751,"title":1752},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fpopover-entry-and-exit-transitions","Popover Menus That Animate From Their Anchor",{"path":1754,"title":1755},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fchoosing-animation-durations","Choosing Animation Durations: How Long Motion Should Last",{"path":1757,"title":1758},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fcubic-bezier-overshoot-and-anticipation","Overshoot and Anticipation With cubic-bezier(): Motion With Character",{"path":1760,"title":1761},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fentry-vs-exit-easing","Entry vs Exit Easing: Different Curves for Arriving and Leaving",{"path":1763,"title":1764},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design","Easing & Motion Design: Making CSS Motion Feel Intentional",{"path":1766,"title":1767},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Flinear-easing-function-for-springs","Spring and Bounce Easing With linear(): Physical Motion Without JavaScript",{"path":1769,"title":1770},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fsteps-easing-for-sprite-animations","steps() Easing: Sprite Sheets, Typewriters and Other Frame-by-Frame Effects",{"path":1772,"title":1773},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Faccessible-css-only-tooltips","Accessible CSS-Only Tooltips and Hover Cards With  and ",{"path":1775,"title":1776},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fbutton-press-and-active-states","Button Press and  States",{"path":1778,"title":1779},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Ffocus-visible-vs-focus-polyfill-alternatives"," vs :focus: Why It Replaced the Focus-Ring Polyfill",{"path":1781,"title":1782},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Ffocus-within-form-patterns"," Form Patterns: Styling a Group From the Field Inside It",{"path":1784,"title":1785},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fhover-intent-delays-with-transition-delay","Hover Intent Delays With transition-delay: Menus That Don't Flicker",{"path":1787,"title":1788},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design","Hover & Focus State Design: Spec-Compliant Patterns for Modern UIs",{"path":1790,"title":1791},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fpointer-and-hover-media-queries","Pointer and Hover Media Queries: Gating Affordances by Input Capability",{"path":1793,"title":1794},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fsmooth-hover-effects-without-javascript","Smooth Hover Effects Without JavaScript: CSS-Only Patterns for Modern UI",{"path":1796,"title":1797},"\u002Fcss-only-micro-interactions-animations","CSS-Only Micro-Interactions & Animations: Architecture, Performance & Implementation",{"path":1799,"title":1800},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fanimation-composition-and-stacking","Stacking Animations With animation-composition",{"path":1802,"title":1803},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fanimation-fill-mode-explained","animation-fill-mode: What an Animation Applies Before and After It Runs",{"path":1805,"title":1806},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcontainer-query-triggered-keyframe-animations","Container-Query-Triggered Keyframe Animations: Animate Differently per Available Space",{"path":1808,"title":1809},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcss-only-accordions-and-disclosure","CSS-Only Accordions and Disclosure Widgets with details and summary",{"path":1811,"title":1812},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcss-only-loading-spinners-and-skeletons","CSS-Only Loading Spinners and Skeleton Shimmer Screens with @keyframes",{"path":1814,"title":1815},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcss-only-toggle-switches-and-checkboxes","CSS-Only Toggle Switches and Checkboxes That Keep the Native Input",{"path":1817,"title":1818},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns","Keyframe Animation Patterns: Spec-Compliant Architectures for Modern UIs",{"path":1820,"title":1821},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fmulti-step-keyframes-and-per-keyframe-easing","Multi-Step Keyframes and Per-Keyframe Easing",{"path":1823,"title":1824},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fstaggered-list-animations-with-custom-properties","Staggered List Animations Using --i Index Custom Properties",{"path":1826,"title":1827},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fanimating-box-shadow-and-filters-cheaply","Animating box-shadow and Filters Cheaply",{"path":1829,"title":1830},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fcontain-property-for-animation-performance","The contain Property for Animation Performance",{"path":1832,"title":1833},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fcss-triggers-layout-paint-composite","Layout, Paint and Composite: What Triggers What",{"path":1835,"title":1836},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration","Performance & GPU Acceleration in CSS: A Developer’s Blueprint",{"path":1838,"title":1839},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Foptimizing-css-animations-for-60fps","Optimizing CSS Animations for 60fps: Budgeting the Frame",{"path":1841,"title":1842},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fprofiling-animations-in-devtools","Profiling CSS Animations in DevTools: Finding the Frame That Costs Too Much",{"path":1844,"title":1845},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fwill-change-and-the-compositor-thread","will-change and the Compositor Thread: Layer Promotion Without the Footguns",{"path":1847,"title":1848},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations","Scroll-Driven Animations: Binding Motion to Scroll Position in Pure CSS",{"path":1850,"title":1851},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-driven-animation-fallbacks","Shipping Scroll-Driven Animations Without Breaking Anything",{"path":1853,"title":1854},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-driven-parallax-effects","Scroll-Driven Parallax Effects in CSS",{"path":1856,"title":1857},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-progress-bar-without-javascript","A Reading Progress Bar Driven by scroll(root)",{"path":1859,"title":1860},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-triggered-reveal-animations","Reveal-on-Scroll with view() and animation-range",{"path":1862,"title":1863},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Ftimeline-scope-for-cross-element-animations","timeline-scope for Cross-Element Animations",{"path":1865,"title":1866},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fview-timeline-and-animation-range","View Timelines and animation-range",{"path":1868,"title":1869},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fcross-document-view-transitions","Cross-Document View Transitions",{"path":1871,"title":1872},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers","View Transitions for CSS Developers: the Pseudo-Element Tree, Snapshots, and Named Elements",{"path":1874,"title":1875},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fsame-document-view-transitions","Writing a Same-Document View Transition: the CSS You Actually Author",{"path":1877,"title":1878},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transition-names-shared-elements","view-transition-name and Shared Elements: Morphing a Thumbnail into a Hero",{"path":1880,"title":1881},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transition-types-and-classes","View Transition Types and Classes",{"path":1883,"title":1884},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transitions-for-list-reordering","View Transitions for List Reordering",{"path":1886,"title":1887},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transitions-with-reduced-motion","Honouring prefers-reduced-motion in View Transitions",{"path":352,"title":1889},"Modern CSS Layouts & Micro-Interactions",{"path":1891,"title":1892},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-positioned-tooltips","Anchor-Positioned Tooltips: Tethering, Flipping, and Getting the Semantics Right",{"path":1894,"title":1895},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-positioning-fallbacks","Anchor Positioning Fallbacks: A Graceful Floor for Older Browser Versions",{"path":1897,"title":1898},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-size-for-matching-widths","anchor-size(): Overlays That Match Their Trigger's Size",{"path":1900,"title":1901},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays","CSS Anchor Positioning and Overlays: Tethering Elements Without JavaScript",{"path":1903,"title":1904},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fpopover-attribute-and-css-styling","The popover Attribute: Top-Layer Overlays With No JavaScript",{"path":1906,"title":1907},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fpopover-light-dismiss-and-stacking","Popover Light Dismiss, Nesting and Stacking",{"path":1909,"title":1910},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fposition-area-grid-explained","position-area: The Anchor Placement Grid",{"path":1912,"title":1913},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fcontainer-query-polyfill-tradeoffs","Container Query Polyfills: What They Cost and When to Skip Them",{"path":1915,"title":1916},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Ffeature-detection-with-supports","Feature Detection with @supports: Syntax, Semantics, and the Traps",{"path":1918,"title":1919},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fhandling-container-query-fallbacks-for-older-browsers","Handling Container Query Fallbacks for Older Browsers",{"path":1921,"title":1922},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks","Container Query Fallbacks: Spec-Compliant CSS Strategies for Legacy Browsers",{"path":1924,"title":1925},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fintrinsic-layout-fallbacks-without-queries","Intrinsic Layout Fallbacks: Baselines That Adapt Without Any Query",{"path":1927,"title":1928},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Ftesting-fallbacks-without-old-browsers","Testing CSS Fallbacks Without an Old Browser",{"path":1930,"title":1931},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-queries-inside-css-nesting","Container Queries Inside CSS Nesting: Keeping Responses Next to the Styles They Change",{"path":1933,"title":1934},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-query-range-and-logic-operators","Container Query Range Syntax and Logic Operators",{"path":1936,"title":1937},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-query-units-cqi-cqb-explained","Container Query Units Explained: cqi, cqb, cqw, cqh, cqmin and cqmax",{"path":1939,"title":1940},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-type-size-vs-inline-size","Choosing container-type: inline-size, size, or normal",{"path":1942,"title":1943},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-vs-media-queries-comparison","Container vs Media Queries: Choosing the Right Reference Box",{"path":1945,"title":1946},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fdebugging-container-queries-in-devtools","Debugging Container Queries in DevTools: Why a Rule Doesn't Match",{"path":1948,"title":1949},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fhow-to-use-container-queries-in-production","How to Use Container Queries in Production Without a Rewrite",{"path":1951,"title":1952},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics","Container Query Syntax Basics",{"path":1954,"title":1955},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fnesting-and-naming-container-queries","Nesting and Naming Container Queries: Targeting the Right Ancestor",{"path":1957,"title":1958},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fauto-fit-minmax-responsive-grids","Responsive Grids with repeat(auto-fit, minmax())",{"path":1960,"title":1961},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fbuilding-a-dashboard-with-subgrid","Building a Responsive Dashboard Where Cards Align with Subgrid",{"path":1963,"title":1964},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fgrid-auto-flow-dense-packing","grid-auto-flow: dense for Packed Layouts",{"path":1966,"title":1967},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fgrid-template-areas-responsive-layouts","Responsive Layouts With grid-template-areas: Rearranging Regions by Name",{"path":1969,"title":1970},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fholy-grail-layout-with-grid","The Holy-Grail Layout with CSS Grid and Container Queries",{"path":1972,"title":1973},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts","CSS Grid and Subgrid Layouts for Responsive Interfaces",{"path":1975,"title":1976},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fmasonry-style-layouts-with-grid","Masonry-Style Layouts With the CSS That Ships Today",{"path":1978,"title":1979},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Foverlapping-elements-with-grid-stacking","Overlapping Elements With Grid Stacking: Layers Without position: absolute",{"path":1981,"title":1982},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fsubgrid-vs-nested-grid","Subgrid vs an Independently Nested Grid",{"path":1984,"title":1985},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fcentering-in-css-every-method","Centering in CSS: Every Modern Method and When Each One Breaks",{"path":1987,"title":1988},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-basis-vs-width","flex-basis vs width: Which Size a Flex Item Actually Starts From",{"path":1990,"title":1991},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-grow-and-flex-shrink-explained","flex-grow and flex-shrink Explained",{"path":1993,"title":1994},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-wrap-intrinsic-responsive-rows","Breakpoint-Free Responsive Rows With flex-wrap and flex-basis",{"path":1996,"title":1997},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflexbox-gap-and-spacing","Flexbox gap vs Margins: Spacing Items Without Edge Hacks",{"path":1999,"title":2000},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns","Flexbox Layout Patterns: One-Dimensional Layout for Real Components",{"path":2002,"title":2003},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fsticky-footer-with-flexbox-and-grid","Sticky Footer With Flexbox or Grid: Pinning the Footer on Short Pages",{"path":2005,"title":2006},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Fclamp-vs-media-query-typography","clamp() Fluid Type vs Media-Query Step Typography: Tradeoffs and Anatomy",{"path":2008,"title":2009},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Fdebugging-clamp-values","Debugging clamp(): Values That Are Ignored, Stuck or Never Fluid",{"path":2011,"title":2012},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-line-height-and-measure","Fluid Line Height and Measure: Keeping Text Readable as It Scales",{"path":2014,"title":2015},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-space-scale-with-clamp","Building a Fluid Spacing Scale with clamp() and Container Units",{"path":2017,"title":2018},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-type-accessibility-and-zoom","Fluid Type, Accessibility and Zoom: The vw-Only Trap",{"path":2020,"title":2021},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-typography-without-javascript","Fluid Typography Without JavaScript: A Precision CSS Reference",{"path":2023,"title":2024},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp","Fluid Typography with clamp(): A Practical Guide for Modern CSS",{"path":2026,"title":2027},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ftext-wrap-balance-and-pretty","text-wrap: balance and pretty: Better Line Breaks Without Manual Breaks",{"path":2029,"title":41},"\u002Fmastering-container-queries-responsive-layouts",{"path":2031,"title":2032},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Faspect-ratio-for-responsive-media","Using aspect-ratio for Responsive Media and Preventing Layout Shift",{"path":2034,"title":2035},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fcontent-visibility-and-contain-intrinsic-size","content-visibility and contain-intrinsic-size: Rendering Only What Is Near the Screen",{"path":2037,"title":2038},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques","Intrinsic Sizing Techniques: Modern CSS Layouts for Responsive UI",{"path":2040,"title":2041},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Flayout-widths-with-min-max-clamp","Layout Widths With min(), max() and clamp(): Sizing Without Breakpoints",{"path":2043,"title":2044},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fmin-max-fit-content-explained","min-content, max-content, and fit-content() Explained",{"path":1604,"title":5},{"path":2047,"title":2048},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fpreventing-flex-and-grid-overflow","The min-width: auto Trap in Flex and Grid Layouts",{"path":2050,"title":2051},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcascade-layers-for-reset-and-tokens","Cascade Layers for Reset and Design Tokens",{"path":2053,"title":2054},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcascade-layers-vs-specificity-hacks","Cascade Layers vs Specificity Hacks: Ordering Instead of Escalating",{"path":2056,"title":2057},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcss-scope-for-component-styles","@scope for Component Styles: Short Selectors That Cannot Leak",{"path":2059,"title":2060},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies","Modern CSS Reset Strategies: A Spec-Compliant Foundation",{"path":2062,"title":2063},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Frevert-layer-and-revert-keywords","initial, inherit, unset, revert and revert-layer: Undoing Styles Correctly",{"path":2065,"title":2066},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fwriting-a-minimal-modern-reset","Writing a Minimal Modern CSS Reset: Every Line Justified",{"path":2068,"title":2069},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fcontent-aware-card-layouts-with-has","Content-Aware Card Layouts With :has(): One Component, Many Shapes",{"path":2071,"title":2072},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fempty-and-loading-states-with-has","Empty and Loading States With ()",{"path":2074,"title":2075},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fform-validation-layouts-with-has","Form Validation Layouts With :has(): Styling Groups From Field State",{"path":2077,"title":2078},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fhas-selector-performance",":has() Selector Performance: What Is Cheap, What Is Not, and How to Measure",{"path":2080,"title":2081},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fhas-vs-container-style-queries",":has() vs Container Style Queries: Discovered State and Published State",{"path":2083,"title":2084},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has","Parent-Aware Layouts With :has(): Letting Containers React to Their Contents",{"path":2086,"title":2087},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fquantity-queries-with-has","Quantity Queries With :has(): Layouts That Respond to How Many Items There Are",{"path":2089,"title":2090},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fbuilding-responsive-cards-with-container-queries","Building Responsive Cards with Container Queries: A Production-Ready Guide",{"path":2092,"title":2093},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fcontainer-query-data-tables","Container Query Data Tables: Reflowing Tables to Cards",{"path":2095,"title":2096},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fcontainer-query-sidebar-layouts","Container Query Sidebar Layouts That Travel Between Contexts",{"path":2098,"title":2099},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns","Responsive Component Patterns: Architecture & Implementation",{"path":2101,"title":2102},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-forms-with-container-queries","Responsive Forms with Container Queries: Reflow Without Losing the Wiring",{"path":2104,"title":2105},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-hero-sections-with-container-queries","Responsive Hero Sections With Container Queries",{"path":2107,"title":2108},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-navigation-without-media-queries","Responsive Navigation Without Media Queries Using Container Queries",{"path":2110,"title":2111},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-pricing-tables","Responsive Pricing Tables: Aligned Features, a Clear Recommendation, Any Width",{"path":2113,"title":2114},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Ftabs-that-become-accordions","Tabs That Become an Accordion: One Component, Two Layouts",{"path":2116,"title":2117},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Fcss-only-carousel-with-scroll-snap","A CSS-Only Carousel With Scroll Snap",{"path":2119,"title":2120},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Fhorizontal-scrolling-card-rows","Horizontal Scrolling Card Rows: Swipeable Lists That Stay in Their Lane",{"path":2122,"title":2123},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts","Scroll Snap & Overflow Layouts: Designing Components That Scroll on Purpose",{"path":2125,"title":2126},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Foverscroll-behavior-for-nested-scrolling","overscroll-behavior: Taming Nested Scrolling, Pull-to-Refresh and Back-Swipe",{"path":2128,"title":2129},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Fscroll-margin-and-scroll-padding-for-sticky-headers","scroll-margin and scroll-padding: Keeping Targets Clear of Sticky Headers",{"path":2131,"title":2132},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fcombining-size-and-style-queries","Combining Size and Style Container Queries",{"path":2134,"title":2135},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fcontainer-style-query-theming","Container Style Query Theming: One Token Instead of a Variant Class Matrix",{"path":2137,"title":2138},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state","Style Queries and Container State: Token-Driven Component Variants",{"path":2140,"title":2141},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fstyle-queries-with-custom-properties","Style Queries With Custom Properties: Declaring, Inheriting, and Matching Tokens",{"path":2143,"title":2144},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fstyle-query-component-variants","Component Variants With Style Queries: One Token, Many Looks",{"path":2146,"title":2147},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fstyle-query-fallbacks-and-support","Style Query Fallbacks and Support: Designing for Older Browser Versions",{"path":2149,"title":2150},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fdvh-svh-lvh-mobile-viewport-units","dvh, svh and lvh: Choosing the Right Mobile Viewport Unit",{"path":2152,"title":2153},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Ffull-bleed-sections-in-constrained-layouts","Full-Bleed Sections in a Constrained Layout: Breaking Out Without Breaking the Page",{"path":2155,"title":2156},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout","Viewport Units & Mobile Layout: Designing for the Screen You Actually Get",{"path":2158,"title":2159},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fsafe-area-insets-for-notched-screens","Safe Area Insets: Designing Around Notches, Corners and Home Indicators",{"path":2161,"title":2162},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fviewport-units-vs-container-units","Viewport Units vs Container Units: Choosing the Right Reference Box",{"path":2164,"title":2165},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fvirtual-keyboard-and-interactive-widget","Layouts That Survive the Virtual Keyboard",{"title":2167,"caption":2168,"height":2169,"resizable":386,"html":2170,"css":2171},"object-fit and object-position on generated images","Each tile is the same wide SVG image: cover with the default centre, cover with a left focal point, and contain. Drag the frame to change the tile sizes.",280,"\n\u003Cdiv class=\"gallery\">\n  \u003Cfigure>\u003Cimg class=\"thumb\" src=\"data:image\u002Fsvg+xml,%3Csvg xmlns='http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg' viewBox='0 0 400 200'%3E%3Crect width='400' height='200' fill='%23bae6fd'\u002F%3E%3Ccircle cx='80' cy='100' r='50' fill='%23f97316'\u002F%3E%3Crect x='250' y='60' width='100' height='90' fill='%230ea5e9'\u002F%3E%3C\u002Fsvg%3E\" alt=\"Orange sun at left, blue block at right\" width=\"400\" height=\"200\">\u003Cfigcaption>cover · 50% 50%\u003C\u002Ffigcaption>\u003C\u002Ffigure>\n  \u003Cfigure>\u003Cimg class=\"thumb thumb--left-subject\" src=\"data:image\u002Fsvg+xml,%3Csvg xmlns='http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg' viewBox='0 0 400 200'%3E%3Crect width='400' height='200' fill='%23bae6fd'\u002F%3E%3Ccircle cx='80' cy='100' r='50' fill='%23f97316'\u002F%3E%3Crect x='250' y='60' width='100' height='90' fill='%230ea5e9'\u002F%3E%3C\u002Fsvg%3E\" alt=\"Same image focused on the sun\" width=\"400\" height=\"200\">\u003Cfigcaption>cover · 20% 50%\u003C\u002Ffigcaption>\u003C\u002Ffigure>\n  \u003Cfigure>\u003Cimg class=\"thumb thumb--product\" src=\"data:image\u002Fsvg+xml,%3Csvg xmlns='http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg' viewBox='0 0 400 200'%3E%3Crect width='400' height='200' fill='%23bae6fd'\u002F%3E%3Ccircle cx='80' cy='100' r='50' fill='%23f97316'\u002F%3E%3Crect x='250' y='60' width='100' height='90' fill='%230ea5e9'\u002F%3E%3C\u002Fsvg%3E\" alt=\"Same image uncropped\" width=\"400\" height=\"200\">\u003Cfigcaption>contain\u003C\u002Ffigcaption>\u003C\u002Ffigure>\n\u003C\u002Fdiv>","\nbody { display: block; }\n.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr)); gap: 0.75rem; }\n.gallery figure { margin: 0; }\n.gallery figcaption { font: 12px ui-monospace, monospace; color: var(--demo-muted); margin-top: 0.25rem; }\n.thumb { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; object-position: var(--focus, 50% 50%); border-radius: 8px; background: var(--demo-surface); }\n.thumb--left-subject { --focus: 20% 50%; }\n.thumb--product { object-fit: contain; background: var(--demo-surface); padding: 0.5rem; box-sizing: border-box; }",1789717749955]