[{"data":1,"prerenderedAt":2289},["ShallowReactive",2],{"page-\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fcentering-in-css-every-method":3,"content-all-pages":1725,"live-demo:flexp-centering-methods":2283},{"id":4,"title":5,"body":6,"description":1706,"extension":1707,"meta":1708,"navigation":367,"path":1721,"seo":1722,"stem":1723,"__hash__":1724},"content\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fcentering-in-css-every-method\u002Findex.md","Centering in CSS: Every Modern Method and When Each One Breaks",{"type":7,"value":8,"toc":1696},"minimark",[9,13,28,33,41,44,177,181,184,188,1044,1054,1058,1066,1128,1142,1156,1160,1178,1200,1210,1228,1232,1239,1530,1556,1560,1585,1589,1603,1618,1631,1652,1656,1693],[10,11,5],"h1",{"id":12},"centering-in-css-every-modern-method-and-when-each-one-breaks",[14,15,16,17,22,23,27],"p",{},"\"How do I center a div\" survives as a joke because for a long time the honest answer was \"it depends on six things you have not told me\". Modern CSS reduces it to a handful of methods, each with one clear use, and one trap that none of the short answers mention: what happens when the centered thing is bigger than its container. This page catalogues the methods that remain worth using, shows which one fits which situation, and covers safe alignment so a centered dialog never loses its top edge. It belongs to ",[18,19,21],"a",{"href":20},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002F","Flexbox Layout Patterns"," in the ",[18,24,26],{"href":25},"\u002Fmastering-container-queries-responsive-layouts\u002F","Mastering Container Queries & Responsive Layouts"," guide.",[29,30,32],"h2",{"id":31},"why-there-are-still-several-methods","Why there are still several methods",[14,34,35,36,40],{},"Centering is really two independent questions: along which axes, and in which layout mode the parent already is. Horizontal centering of a block with a known width has worked with ",[37,38,39],"code",{},"margin-inline: auto"," since the earliest CSS. Vertical centering needed a layout mode that distributes free space in the block axis, which ordinary block flow did not do until recently. Grid and flexbox added alignment properties that do both, and the positioning model has its own answer for elements taken out of flow.",[14,42,43],{},"The right method is therefore the one that matches what the parent already is. Switching a parent to grid just to center one child is fine on an empty hero, but on a parent whose other children rely on block flow — margin collapsing, floats, normal wrapping — it changes more than you intended.",[45,46,52,53,52,57,52,61,52,69,52,81,52,86,52,93,52,97,52,104,52,110,52,116,52,121,52,124,52,127,52,131,52,135,52,137,52,141,52,146,52,151,52,154,52,158,52,162,52,166,52,169,52,173],"svg",{"viewBox":47,"role":48,"ariaLabel":49,"xmlns":50,"style":51},"0 0 720 330","img","Decision tree choosing a centering method by whether the element is in flow and what the parent's display is","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","width:100%;height:auto;max-width:720px;margin:2rem 0","\n  ",[54,55,56],"title",{},"Choosing a centering method",[58,59,60],"desc",{},"Out-of-flow elements use inset zero with margin auto. In-flow elements in a grid parent use place-items, in a flex parent use justify-content and align-items, and in a block parent use margin-inline auto horizontally and align-content vertically.",[62,63,68],"text",{"textAnchor":64,"x":65,"y":66,"style":67},"middle","360","26","text-anchor:middle;fill:currentColor;font:700 17px sans-serif","Start from what the parent already is",[70,71],"rect",{"x":72,"y":73,"width":74,"height":75,"rx":76,"fill":77,"stroke":78,"strokeWidth":79,"opacity":80},"250","44","220","40","8","none","currentColor","1.5","0.6",[62,82,85],{"textAnchor":64,"x":65,"y":83,"style":84},"69","text-anchor:middle;fill:currentColor;font:13px sans-serif","Is the element in flow?",[87,88],"line",{"x1":89,"y1":90,"x2":91,"y2":92,"stroke":78,"strokeWidth":79,"opacity":80},"300","84","160","120",[87,94],{"x1":95,"y1":90,"x2":96,"y2":92,"stroke":78,"strokeWidth":79,"opacity":80},"420","560",[62,98,103],{"textAnchor":99,"x":100,"y":101,"style":102},"end","222","98","text-anchor:end;fill:currentColor;font:12px sans-serif","no, positioned",[62,105,109],{"textAnchor":106,"x":107,"y":101,"style":108},"start","498","text-anchor:start;fill:currentColor;font:12px sans-serif","yes",[70,111],{"x":75,"y":92,"width":112,"height":113,"rx":76,"fill":114,"opacity":115},"240","52","#7aa2ff","0.3",[62,117,120],{"textAnchor":64,"x":91,"y":118,"style":119},"142","text-anchor:middle;fill:currentColor;font:12px ui-monospace,monospace","position: absolute;",[62,122,123],{"textAnchor":64,"x":91,"y":91,"style":119},"inset: 0; margin: auto",[70,125],{"x":126,"y":92,"width":74,"height":75,"rx":76,"fill":77,"stroke":78,"strokeWidth":79,"opacity":80},"450",[62,128,130],{"textAnchor":64,"x":96,"y":129,"style":84},"145","Parent display?",[87,132],{"x1":133,"y1":91,"x2":65,"y2":134,"stroke":78,"strokeWidth":79,"opacity":80},"500","210",[87,136],{"x1":96,"y1":91,"x2":96,"y2":134,"stroke":78,"strokeWidth":79,"opacity":80},[87,138],{"x1":139,"y1":91,"x2":140,"y2":72,"stroke":78,"strokeWidth":79,"opacity":80},"620","640",[70,142],{"x":143,"y":134,"width":144,"height":145,"rx":76,"fill":114,"opacity":115},"270","180","50",[62,147,150],{"textAnchor":64,"x":65,"y":148,"style":149},"232","text-anchor:middle;fill:currentColor;font:600 12px sans-serif","grid",[62,152,153],{"textAnchor":64,"x":65,"y":72,"style":119},"place-items: center",[70,155],{"x":156,"y":134,"width":157,"height":145,"rx":76,"fill":114,"opacity":115},"462","126",[62,159,161],{"textAnchor":64,"x":160,"y":148,"style":149},"525","flex",[62,163,165],{"textAnchor":64,"x":160,"y":72,"style":164},"text-anchor:middle;fill:currentColor;font:11px ui-monospace,monospace","justify + align",[70,167],{"x":168,"y":143,"width":91,"height":145,"rx":76,"fill":114,"opacity":115},"540",[62,170,172],{"textAnchor":64,"x":139,"y":171,"style":149},"292","block",[62,174,176],{"textAnchor":64,"x":139,"y":175,"style":164},"310","align-content",[29,178,180],{"id":179},"the-complete-implementation","The complete implementation",[14,182,183],{},"Each numbered block below is a complete, independent centering method. They share one page so they can be compared; in practice you would use one.",[185,186],"live-demo",{"name":187},"flexp-centering-methods",[189,190,195],"pre",{"className":191,"code":192,"language":193,"meta":194,"style":194},"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\u003Ctitle>Centering methods\u003C\u002Ftitle>\n\u003Cstyle>\n  body { font: 14px\u002F1.4 system-ui, sans-serif; margin: 1rem; display: grid; gap: 1rem; }\n\n  .box {\n    height: 5rem;\n    border: 1px dashed #94a3b8;\n    border-radius: 8px;\n  }\n  .item { padding: 0.5rem 0.75rem; border-radius: 6px; background: #dbeafe; color: #1e3a8a; }\n\n  \u002F* 1. Grid: one declaration on the parent, child needs nothing. *\u002F\n  .grid-center { display: grid; place-items: center; }\n\n  \u002F* 2. Flexbox: main axis with justify-content, cross axis with align-items. *\u002F\n  .flex-center { display: flex; justify-content: center; align-items: center; }\n\n  \u002F* 3. Auto margins inside flex or grid: free space is absorbed equally\n     on both sides. Unlike 'center', this never pushes content past the\n     start edge when it overflows (see the safe-centering section). *\u002F\n  .margin-center { display: flex; }\n  .margin-center > .item { margin: auto; }\n\n  \u002F* 4. Block container: align-content now works without changing display,\n     and margin-inline: auto centers a child that has a width. *\u002F\n  .block-center { align-content: center; }\n  .block-center > .item { width: fit-content; margin-inline: auto; }\n\n  \u002F* 5. Out of flow: stretch the containing block edges with inset: 0,\n     then let auto margins split the leftover space. The element needs a\n     size (here fit-content) or it simply fills the container. *\u002F\n  .abs-parent { position: relative; }\n  .abs-parent > .item {\n    position: absolute;\n    inset: 0;\n    width: fit-content;\n    height: fit-content;\n    margin: auto;\n  }\n\u003C\u002Fstyle>\n\u003C\u002Fhead>\n\u003Cbody>\n  \u003Cdiv class=\"box grid-center\">\u003Cspan class=\"item\">1 · grid\u003C\u002Fspan>\u003C\u002Fdiv>\n  \u003Cdiv class=\"box flex-center\">\u003Cspan class=\"item\">2 · flex\u003C\u002Fspan>\u003C\u002Fdiv>\n  \u003Cdiv class=\"box margin-center\">\u003Cspan class=\"item\">3 · auto margins\u003C\u002Fspan>\u003C\u002Fdiv>\n  \u003Cdiv class=\"box block-center\">\u003Cdiv class=\"item\">4 · block align-content\u003C\u002Fdiv>\u003C\u002Fdiv>\n  \u003Cdiv class=\"box abs-parent\">\u003Cspan class=\"item\">5 · inset + margin\u003C\u002Fspan>\u003C\u002Fdiv>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n","html","",[37,196,197,216,236,246,264,278,288,362,369,378,394,414,428,434,491,496,503,529,534,540,574,579,585,591,597,613,635,640,646,652,668,698,703,709,715,721,739,750,763,776,788,799,811,816,826,835,845,886,921,956,991,1026,1035],{"__ignoreMap":194},[198,199,201,205,209,213],"span",{"class":87,"line":200},1,[198,202,204],{"class":203},"suds8","\u003C!",[198,206,208],{"class":207},"sne4z","doctype",[198,210,212],{"class":211},"s-5SL"," html",[198,214,215],{"class":203},">\n",[198,217,219,222,224,227,230,234],{"class":87,"line":218},2,[198,220,221],{"class":203},"\u003C",[198,223,193],{"class":207},[198,225,226],{"class":211}," lang",[198,228,229],{"class":203},"=",[198,231,233],{"class":232},"sT6z2","\"en\"",[198,235,215],{"class":203},[198,237,239,241,244],{"class":87,"line":238},3,[198,240,221],{"class":203},[198,242,243],{"class":207},"head",[198,245,215],{"class":203},[198,247,249,251,254,257,259,262],{"class":87,"line":248},4,[198,250,221],{"class":203},[198,252,253],{"class":207},"meta",[198,255,256],{"class":211}," charset",[198,258,229],{"class":203},[198,260,261],{"class":232},"\"utf-8\"",[198,263,215],{"class":203},[198,265,267,269,271,274,276],{"class":87,"line":266},5,[198,268,221],{"class":203},[198,270,54],{"class":207},[198,272,273],{"class":203},">Centering methods\u003C\u002F",[198,275,54],{"class":207},[198,277,215],{"class":203},[198,279,281,283,286],{"class":87,"line":280},6,[198,282,221],{"class":203},[198,284,285],{"class":207},"style",[198,287,215],{"class":203},[198,289,291,294,297,300,303,306,310,313,316,319,322,325,328,331,333,336,339,341,344,346,348,350,353,355,357,359],{"class":87,"line":290},7,[198,292,293],{"class":207},"  body",[198,295,296],{"class":203}," { ",[198,298,299],{"class":211},"font",[198,301,302],{"class":203},": ",[198,304,305],{"class":211},"14",[198,307,309],{"class":308},"sHUrx","px",[198,311,312],{"class":203},"\u002F",[198,314,315],{"class":211},"1.4",[198,317,318],{"class":211}," system-ui",[198,320,321],{"class":203},", ",[198,323,324],{"class":211},"sans-serif",[198,326,327],{"class":203},"; ",[198,329,330],{"class":211},"margin",[198,332,302],{"class":203},[198,334,335],{"class":211},"1",[198,337,338],{"class":308},"rem",[198,340,327],{"class":203},[198,342,343],{"class":211},"display",[198,345,302],{"class":203},[198,347,150],{"class":211},[198,349,327],{"class":203},[198,351,352],{"class":211},"gap",[198,354,302],{"class":203},[198,356,335],{"class":211},[198,358,338],{"class":308},[198,360,361],{"class":203},"; }\n",[198,363,365],{"class":87,"line":364},8,[198,366,368],{"emptyLinePlaceholder":367},true,"\n",[198,370,372,375],{"class":87,"line":371},9,[198,373,374],{"class":211},"  .box",[198,376,377],{"class":203}," {\n",[198,379,381,384,386,389,391],{"class":87,"line":380},10,[198,382,383],{"class":211},"    height",[198,385,302],{"class":203},[198,387,388],{"class":211},"5",[198,390,338],{"class":308},[198,392,393],{"class":203},";\n",[198,395,397,400,402,404,406,409,412],{"class":87,"line":396},11,[198,398,399],{"class":211},"    border",[198,401,302],{"class":203},[198,403,335],{"class":211},[198,405,309],{"class":308},[198,407,408],{"class":211}," dashed",[198,410,411],{"class":211}," #94a3b8",[198,413,393],{"class":203},[198,415,417,420,422,424,426],{"class":87,"line":416},12,[198,418,419],{"class":211},"    border-radius",[198,421,302],{"class":203},[198,423,76],{"class":211},[198,425,309],{"class":308},[198,427,393],{"class":203},[198,429,431],{"class":87,"line":430},13,[198,432,433],{"class":203},"  }\n",[198,435,437,440,442,445,447,450,452,455,457,459,462,464,467,469,471,474,476,479,481,484,486,489],{"class":87,"line":436},14,[198,438,439],{"class":211},"  .item",[198,441,296],{"class":203},[198,443,444],{"class":211},"padding",[198,446,302],{"class":203},[198,448,449],{"class":211},"0.5",[198,451,338],{"class":308},[198,453,454],{"class":211}," 0.75",[198,456,338],{"class":308},[198,458,327],{"class":203},[198,460,461],{"class":211},"border-radius",[198,463,302],{"class":203},[198,465,466],{"class":211},"6",[198,468,309],{"class":308},[198,470,327],{"class":203},[198,472,473],{"class":211},"background",[198,475,302],{"class":203},[198,477,478],{"class":211},"#dbeafe",[198,480,327],{"class":203},[198,482,483],{"class":211},"color",[198,485,302],{"class":203},[198,487,488],{"class":211},"#1e3a8a",[198,490,361],{"class":203},[198,492,494],{"class":87,"line":493},15,[198,495,368],{"emptyLinePlaceholder":367},[198,497,499],{"class":87,"line":498},16,[198,500,502],{"class":501},"sLBg1","  \u002F* 1. Grid: one declaration on the parent, child needs nothing. *\u002F\n",[198,504,506,509,511,513,515,517,519,522,524,527],{"class":87,"line":505},17,[198,507,508],{"class":211},"  .grid-center",[198,510,296],{"class":203},[198,512,343],{"class":211},[198,514,302],{"class":203},[198,516,150],{"class":211},[198,518,327],{"class":203},[198,520,521],{"class":211},"place-items",[198,523,302],{"class":203},[198,525,526],{"class":211},"center",[198,528,361],{"class":203},[198,530,532],{"class":87,"line":531},18,[198,533,368],{"emptyLinePlaceholder":367},[198,535,537],{"class":87,"line":536},19,[198,538,539],{"class":501},"  \u002F* 2. Flexbox: main axis with justify-content, cross axis with align-items. *\u002F\n",[198,541,543,546,548,550,552,554,556,559,561,563,565,568,570,572],{"class":87,"line":542},20,[198,544,545],{"class":211},"  .flex-center",[198,547,296],{"class":203},[198,549,343],{"class":211},[198,551,302],{"class":203},[198,553,161],{"class":211},[198,555,327],{"class":203},[198,557,558],{"class":211},"justify-content",[198,560,302],{"class":203},[198,562,526],{"class":211},[198,564,327],{"class":203},[198,566,567],{"class":211},"align-items",[198,569,302],{"class":203},[198,571,526],{"class":211},[198,573,361],{"class":203},[198,575,577],{"class":87,"line":576},21,[198,578,368],{"emptyLinePlaceholder":367},[198,580,582],{"class":87,"line":581},22,[198,583,584],{"class":501},"  \u002F* 3. Auto margins inside flex or grid: free space is absorbed equally\n",[198,586,588],{"class":87,"line":587},23,[198,589,590],{"class":501},"     on both sides. Unlike 'center', this never pushes content past the\n",[198,592,594],{"class":87,"line":593},24,[198,595,596],{"class":501},"     start edge when it overflows (see the safe-centering section). *\u002F\n",[198,598,600,603,605,607,609,611],{"class":87,"line":599},25,[198,601,602],{"class":211},"  .margin-center",[198,604,296],{"class":203},[198,606,343],{"class":211},[198,608,302],{"class":203},[198,610,161],{"class":211},[198,612,361],{"class":203},[198,614,616,618,621,624,626,628,630,633],{"class":87,"line":615},26,[198,617,602],{"class":211},[198,619,620],{"class":308}," >",[198,622,623],{"class":211}," .item",[198,625,296],{"class":203},[198,627,330],{"class":211},[198,629,302],{"class":203},[198,631,632],{"class":211},"auto",[198,634,361],{"class":203},[198,636,638],{"class":87,"line":637},27,[198,639,368],{"emptyLinePlaceholder":367},[198,641,643],{"class":87,"line":642},28,[198,644,645],{"class":501},"  \u002F* 4. Block container: align-content now works without changing display,\n",[198,647,649],{"class":87,"line":648},29,[198,650,651],{"class":501},"     and margin-inline: auto centers a child that has a width. *\u002F\n",[198,653,655,658,660,662,664,666],{"class":87,"line":654},30,[198,656,657],{"class":211},"  .block-center",[198,659,296],{"class":203},[198,661,176],{"class":211},[198,663,302],{"class":203},[198,665,526],{"class":211},[198,667,361],{"class":203},[198,669,671,673,675,677,679,682,684,687,689,692,694,696],{"class":87,"line":670},31,[198,672,657],{"class":211},[198,674,620],{"class":308},[198,676,623],{"class":211},[198,678,296],{"class":203},[198,680,681],{"class":211},"width",[198,683,302],{"class":203},[198,685,686],{"class":211},"fit-content",[198,688,327],{"class":203},[198,690,691],{"class":211},"margin-inline",[198,693,302],{"class":203},[198,695,632],{"class":211},[198,697,361],{"class":203},[198,699,701],{"class":87,"line":700},32,[198,702,368],{"emptyLinePlaceholder":367},[198,704,706],{"class":87,"line":705},33,[198,707,708],{"class":501},"  \u002F* 5. Out of flow: stretch the containing block edges with inset: 0,\n",[198,710,712],{"class":87,"line":711},34,[198,713,714],{"class":501},"     then let auto margins split the leftover space. The element needs a\n",[198,716,718],{"class":87,"line":717},35,[198,719,720],{"class":501},"     size (here fit-content) or it simply fills the container. *\u002F\n",[198,722,724,727,729,732,734,737],{"class":87,"line":723},36,[198,725,726],{"class":211},"  .abs-parent",[198,728,296],{"class":203},[198,730,731],{"class":211},"position",[198,733,302],{"class":203},[198,735,736],{"class":211},"relative",[198,738,361],{"class":203},[198,740,742,744,746,748],{"class":87,"line":741},37,[198,743,726],{"class":211},[198,745,620],{"class":308},[198,747,623],{"class":211},[198,749,377],{"class":203},[198,751,753,756,758,761],{"class":87,"line":752},38,[198,754,755],{"class":211},"    position",[198,757,302],{"class":203},[198,759,760],{"class":211},"absolute",[198,762,393],{"class":203},[198,764,766,769,771,774],{"class":87,"line":765},39,[198,767,768],{"class":211},"    inset",[198,770,302],{"class":203},[198,772,773],{"class":211},"0",[198,775,393],{"class":203},[198,777,779,782,784,786],{"class":87,"line":778},40,[198,780,781],{"class":211},"    width",[198,783,302],{"class":203},[198,785,686],{"class":211},[198,787,393],{"class":203},[198,789,791,793,795,797],{"class":87,"line":790},41,[198,792,383],{"class":211},[198,794,302],{"class":203},[198,796,686],{"class":211},[198,798,393],{"class":203},[198,800,802,805,807,809],{"class":87,"line":801},42,[198,803,804],{"class":211},"    margin",[198,806,302],{"class":203},[198,808,632],{"class":211},[198,810,393],{"class":203},[198,812,814],{"class":87,"line":813},43,[198,815,433],{"class":203},[198,817,819,822,824],{"class":87,"line":818},44,[198,820,821],{"class":203},"\u003C\u002F",[198,823,285],{"class":207},[198,825,215],{"class":203},[198,827,829,831,833],{"class":87,"line":828},45,[198,830,821],{"class":203},[198,832,243],{"class":207},[198,834,215],{"class":203},[198,836,838,840,843],{"class":87,"line":837},46,[198,839,221],{"class":203},[198,841,842],{"class":207},"body",[198,844,215],{"class":203},[198,846,848,851,854,857,859,862,865,867,869,871,874,877,879,882,884],{"class":87,"line":847},47,[198,849,850],{"class":203},"  \u003C",[198,852,853],{"class":207},"div",[198,855,856],{"class":211}," class",[198,858,229],{"class":203},[198,860,861],{"class":232},"\"box grid-center\"",[198,863,864],{"class":203},">\u003C",[198,866,198],{"class":207},[198,868,856],{"class":211},[198,870,229],{"class":203},[198,872,873],{"class":232},"\"item\"",[198,875,876],{"class":203},">1 · grid\u003C\u002F",[198,878,198],{"class":207},[198,880,881],{"class":203},">\u003C\u002F",[198,883,853],{"class":207},[198,885,215],{"class":203},[198,887,889,891,893,895,897,900,902,904,906,908,910,913,915,917,919],{"class":87,"line":888},48,[198,890,850],{"class":203},[198,892,853],{"class":207},[198,894,856],{"class":211},[198,896,229],{"class":203},[198,898,899],{"class":232},"\"box flex-center\"",[198,901,864],{"class":203},[198,903,198],{"class":207},[198,905,856],{"class":211},[198,907,229],{"class":203},[198,909,873],{"class":232},[198,911,912],{"class":203},">2 · flex\u003C\u002F",[198,914,198],{"class":207},[198,916,881],{"class":203},[198,918,853],{"class":207},[198,920,215],{"class":203},[198,922,924,926,928,930,932,935,937,939,941,943,945,948,950,952,954],{"class":87,"line":923},49,[198,925,850],{"class":203},[198,927,853],{"class":207},[198,929,856],{"class":211},[198,931,229],{"class":203},[198,933,934],{"class":232},"\"box margin-center\"",[198,936,864],{"class":203},[198,938,198],{"class":207},[198,940,856],{"class":211},[198,942,229],{"class":203},[198,944,873],{"class":232},[198,946,947],{"class":203},">3 · auto margins\u003C\u002F",[198,949,198],{"class":207},[198,951,881],{"class":203},[198,953,853],{"class":207},[198,955,215],{"class":203},[198,957,959,961,963,965,967,970,972,974,976,978,980,983,985,987,989],{"class":87,"line":958},50,[198,960,850],{"class":203},[198,962,853],{"class":207},[198,964,856],{"class":211},[198,966,229],{"class":203},[198,968,969],{"class":232},"\"box block-center\"",[198,971,864],{"class":203},[198,973,853],{"class":207},[198,975,856],{"class":211},[198,977,229],{"class":203},[198,979,873],{"class":232},[198,981,982],{"class":203},">4 · block align-content\u003C\u002F",[198,984,853],{"class":207},[198,986,881],{"class":203},[198,988,853],{"class":207},[198,990,215],{"class":203},[198,992,994,996,998,1000,1002,1005,1007,1009,1011,1013,1015,1018,1020,1022,1024],{"class":87,"line":993},51,[198,995,850],{"class":203},[198,997,853],{"class":207},[198,999,856],{"class":211},[198,1001,229],{"class":203},[198,1003,1004],{"class":232},"\"box abs-parent\"",[198,1006,864],{"class":203},[198,1008,198],{"class":207},[198,1010,856],{"class":211},[198,1012,229],{"class":203},[198,1014,873],{"class":232},[198,1016,1017],{"class":203},">5 · inset + margin\u003C\u002F",[198,1019,198],{"class":207},[198,1021,881],{"class":203},[198,1023,853],{"class":207},[198,1025,215],{"class":203},[198,1027,1029,1031,1033],{"class":87,"line":1028},52,[198,1030,821],{"class":203},[198,1032,842],{"class":207},[198,1034,215],{"class":203},[198,1036,1038,1040,1042],{"class":87,"line":1037},53,[198,1039,821],{"class":203},[198,1041,193],{"class":207},[198,1043,215],{"class":203},[14,1045,1046,1047,1049,1050,1053],{},"Method 1 is the default choice for a single child: the smallest amount of CSS, no rule on the child, and it works whether the child is text, an image or a component. Method 2 is the right choice when the parent is already a flex row for other reasons. Method 3 looks redundant but is quietly the most robust, for reasons covered in the key technique section. Method 4 is new: ",[37,1048,176],{}," used to be ignored on block containers, and now centers their content in the block axis without switching layout modes. Method 5 replaces the older ",[37,1051,1052],{},"top: 50%; left: 50%; transform: translate(-50%, -50%)"," idiom.",[29,1055,1057],{"id":1056},"the-key-technique-safe-centering-and-auto-margins","The key technique: safe centering and auto margins",[14,1059,1060,1061,1065],{},"Every centering method distributes free space. When the child is ",[1062,1063,1064],"em",{},"larger"," than the container, the free space is negative, and \"center\" distributes the overflow equally on both sides. Half of the child now sits above or before the container's start edge, and because scrolling can never reach negative offsets, that half is unreachable. On a login dialog taller than a landscape phone, the heading and the first field vanish.",[45,1067,52,1070,52,1073,52,1076,52,1079,52,1085,52,1091,52,1096,52,1101,52,1105,52,1109,52,1113,52,1115,52,1118,52,1120,52,1123],{"viewBox":1068,"role":48,"ariaLabel":1069,"xmlns":50,"style":51},"0 0 720 320","An oversized child centered with plain center overflows above the container; with safe center it aligns to the top and overflows downward only",[54,1071,1072],{},"Unsafe versus safe centering with overflow",[58,1074,1075],{},"Left, a tall child centered in a short container extends above the top edge where it cannot be scrolled to. Right, with safe center it starts at the top edge and extends downward, where scrolling can reach it.",[62,1077,1078],{"textAnchor":64,"x":65,"y":66,"style":67},"When the child is taller than the container",[62,1080,1084],{"textAnchor":64,"x":1081,"y":1082,"style":1083},"190","56","text-anchor:middle;fill:currentColor;font:600 13px ui-monospace,monospace","align-items: center",[70,1086],{"x":1087,"y":1088,"width":91,"height":1089,"rx":466,"fill":114,"opacity":1090},"110","70","200","0.18",[1092,1093],"path",{"d":1094,"fill":77,"stroke":78,"strokeWidth":1095},"M90 120 H290 V220 H90 Z","2",[62,1097,1100],{"textAnchor":64,"x":1081,"y":1098,"style":1099},"96","text-anchor:middle;fill:currentColor;font:12px sans-serif","unreachable",[62,1102,1104],{"textAnchor":64,"x":1081,"y":1103,"style":1099},"175","container",[62,1106,1108],{"textAnchor":64,"x":1081,"y":1107,"style":1099},"252","scrollable",[62,1110,1112],{"textAnchor":64,"x":1111,"y":1082,"style":1083},"530","align-items: safe center",[70,1114],{"x":126,"y":92,"width":91,"height":1089,"rx":466,"fill":114,"opacity":1090},[1092,1116],{"d":1117,"fill":77,"stroke":78,"strokeWidth":1095},"M430 120 H630 V220 H430 Z",[62,1119,1104],{"textAnchor":64,"x":1111,"y":1103,"style":1099},[62,1121,1122],{"textAnchor":64,"x":1111,"y":143,"style":1099},"scrollable overflow",[62,1124,1127],{"textAnchor":64,"x":65,"y":1125,"style":1126},"306","text-anchor:middle;fill:currentColor;font:12px sans-serif;opacity:0.75","safe falls back to start alignment whenever centering would overflow the start edge.",[14,1129,1130,1131,1134,1135,1137,1138,1141],{},"The alignment properties accept a ",[37,1132,1133],{},"safe"," keyword that fixes this: ",[37,1136,1112],{}," centers while there is room and switches to start alignment as soon as centering would push content past the start edge. ",[37,1139,1140],{},"unsafe"," is the explicit opposite, and the default when neither is written behaves like unsafe in most real cases.",[14,1143,1144,1145,1148,1149,1152,1153,1155],{},"Auto margins get the safe behaviour for free. An auto margin absorbs ",[1062,1146,1147],{},"positive"," free space and resolves to zero when free space is negative, so a child with ",[37,1150,1151],{},"margin: auto"," in a flex or grid parent is centered when it fits and start-aligned when it does not. That is why method 3 is recommended for anything that might outgrow its container — dialogs, full-screen overlays, empty states with long translated text — even though ",[37,1154,153],{}," is shorter.",[29,1157,1159],{"id":1158},"centering-text-is-a-different-problem","Centering text is a different problem",[14,1161,1162,1163,1166,1167,1170,1171,1173,1174,1177],{},"Much of the confusion around centering comes from mixing up two operations. ",[37,1164,1165],{},"text-align: center"," does not move boxes at all; it aligns the ",[1062,1168,1169],{},"inline content"," inside each line box of a block. A paragraph with ",[37,1172,1165],{}," is still full width, and its lines are centered inside that width. Put a button inside it and the button is centered too, because a button is an inline-level box sitting on a line. Put a ",[37,1175,1176],{},"\u003Cdiv>"," inside it and nothing happens to the div's position, because block-level boxes do not sit on lines.",[14,1179,1180,1181,1184,1185,1188,1189,1191,1192,1195,1196,1199],{},"That distinction explains a common bug. A card title centered with ",[37,1182,1183],{},"text-align"," looks right until it wraps onto two lines, at which point each line is centered independently and the ragged, diamond-shaped result looks odd in a narrow card. If the intent was \"center this block of text as a unit, with its lines left-aligned\", the tool is box centering: give the heading ",[37,1186,1187],{},"width: fit-content"," and ",[37,1190,39],{},", and keep ",[37,1193,1194],{},"text-align: start",". If the intent really was centered lines, ",[37,1197,1198],{},"text-wrap: balance"," — supported in Chrome and Edge 114, Firefox 121 and Safari 17.5 — evens out the line lengths so a two-line centered title stops looking lopsided.",[14,1201,1202,1203,1206,1207,1209],{},"Vertical centering of a single line of text inside a fixed-height box has its own old trick: setting ",[37,1204,1205],{},"line-height"," equal to the box height. It still works, and it still breaks the moment the text wraps, because the second line doubles the content height. Any of the layout methods above handle wrapping correctly, so treat the ",[37,1208,1205],{}," trick as legacy code to replace when you touch it.",[14,1211,1212,1213,1215,1216,1219,1220,1223,1224,1227],{},"Finally, icons next to text. Centering an icon against a line of text with ",[37,1214,1084],{}," on a flex row centers the icon against the ",[1062,1217,1218],{},"line box",", which includes the font's ascender and descender space, so a small icon often looks slightly low. Aligning to the first baseline with ",[37,1221,1222],{},"align-items: baseline",", or nudging the icon with ",[37,1225,1226],{},"vertical-align: -0.125em"," in inline flow, usually looks more deliberate than geometric centering — optical alignment beats mathematical alignment for glyph-sized things.",[29,1229,1231],{"id":1230},"variation-centering-a-modal-overlay","Variation: centering a modal overlay",[14,1233,1234,1235,1238],{},"A modal combines several of these ideas: an out-of-flow overlay covering the viewport, a dialog centered inside it, and a guarantee that a tall dialog stays reachable. The native ",[37,1236,1237],{},"\u003Cdialog>"," element's modal form already centers itself with auto margins; the rules below make a custom overlay behave the same way.",[189,1240,1244],{"className":1241,"code":1242,"language":1243,"meta":194,"style":194},"language-css shiki shiki-themes github-light-high-contrast github-dark-high-contrast",".overlay {\n  position: fixed;\n  inset: 0;\n  display: grid;\n  \u002F* safe keeps a tall dialog's heading on screen on short viewports *\u002F\n  place-items: safe center;\n  padding: 1rem;\n  overflow-y: auto;              \u002F* the overlay, not the page, scrolls *\u002F\n  background: rgb(15 23 42 \u002F 0.55);\n}\n\n.overlay__dialog {\n  width: min(100%, 32rem);\n  padding: 1.5rem;\n  border-radius: 12px;\n  background: #ffffff;\n  color: #0f172a;\n}\n\n\u002F* Fallback for engines without the safe keyword: auto margins\n   provide the same start-alignment on overflow. *\u002F\n@supports not (align-items: safe center) {\n  .overlay { place-items: start stretch; }\n  .overlay__dialog { margin: auto; }\n}\n","css",[37,1245,1246,1253,1265,1276,1287,1292,1304,1317,1332,1363,1368,1372,1379,1406,1418,1432,1443,1455,1459,1463,1468,1473,1493,1511,1526],{"__ignoreMap":194},[198,1247,1248,1251],{"class":87,"line":200},[198,1249,1250],{"class":211},".overlay",[198,1252,377],{"class":203},[198,1254,1255,1258,1260,1263],{"class":87,"line":218},[198,1256,1257],{"class":211},"  position",[198,1259,302],{"class":203},[198,1261,1262],{"class":211},"fixed",[198,1264,393],{"class":203},[198,1266,1267,1270,1272,1274],{"class":87,"line":238},[198,1268,1269],{"class":211},"  inset",[198,1271,302],{"class":203},[198,1273,773],{"class":211},[198,1275,393],{"class":203},[198,1277,1278,1281,1283,1285],{"class":87,"line":248},[198,1279,1280],{"class":211},"  display",[198,1282,302],{"class":203},[198,1284,150],{"class":211},[198,1286,393],{"class":203},[198,1288,1289],{"class":87,"line":266},[198,1290,1291],{"class":501},"  \u002F* safe keeps a tall dialog's heading on screen on short viewports *\u002F\n",[198,1293,1294,1297,1300,1302],{"class":87,"line":280},[198,1295,1296],{"class":211},"  place-items",[198,1298,1299],{"class":203},": safe ",[198,1301,526],{"class":211},[198,1303,393],{"class":203},[198,1305,1306,1309,1311,1313,1315],{"class":87,"line":290},[198,1307,1308],{"class":211},"  padding",[198,1310,302],{"class":203},[198,1312,335],{"class":211},[198,1314,338],{"class":308},[198,1316,393],{"class":203},[198,1318,1319,1322,1324,1326,1329],{"class":87,"line":364},[198,1320,1321],{"class":211},"  overflow-y",[198,1323,302],{"class":203},[198,1325,632],{"class":211},[198,1327,1328],{"class":203},";              ",[198,1330,1331],{"class":501},"\u002F* the overlay, not the page, scrolls *\u002F\n",[198,1333,1334,1337,1339,1342,1345,1348,1351,1354,1357,1360],{"class":87,"line":371},[198,1335,1336],{"class":211},"  background",[198,1338,302],{"class":203},[198,1340,1341],{"class":211},"rgb",[198,1343,1344],{"class":203},"(",[198,1346,1347],{"class":211},"15",[198,1349,1350],{"class":211}," 23",[198,1352,1353],{"class":211}," 42",[198,1355,1356],{"class":203}," \u002F ",[198,1358,1359],{"class":211},"0.55",[198,1361,1362],{"class":203},");\n",[198,1364,1365],{"class":87,"line":380},[198,1366,1367],{"class":203},"}\n",[198,1369,1370],{"class":87,"line":396},[198,1371,368],{"emptyLinePlaceholder":367},[198,1373,1374,1377],{"class":87,"line":416},[198,1375,1376],{"class":211},".overlay__dialog",[198,1378,377],{"class":203},[198,1380,1381,1384,1386,1389,1391,1394,1397,1399,1402,1404],{"class":87,"line":430},[198,1382,1383],{"class":211},"  width",[198,1385,302],{"class":203},[198,1387,1388],{"class":211},"min",[198,1390,1344],{"class":203},[198,1392,1393],{"class":211},"100",[198,1395,1396],{"class":308},"%",[198,1398,321],{"class":203},[198,1400,1401],{"class":211},"32",[198,1403,338],{"class":308},[198,1405,1362],{"class":203},[198,1407,1408,1410,1412,1414,1416],{"class":87,"line":436},[198,1409,1308],{"class":211},[198,1411,302],{"class":203},[198,1413,79],{"class":211},[198,1415,338],{"class":308},[198,1417,393],{"class":203},[198,1419,1420,1423,1425,1428,1430],{"class":87,"line":493},[198,1421,1422],{"class":211},"  border-radius",[198,1424,302],{"class":203},[198,1426,1427],{"class":211},"12",[198,1429,309],{"class":308},[198,1431,393],{"class":203},[198,1433,1434,1436,1438,1441],{"class":87,"line":498},[198,1435,1336],{"class":211},[198,1437,302],{"class":203},[198,1439,1440],{"class":211},"#ffffff",[198,1442,393],{"class":203},[198,1444,1445,1448,1450,1453],{"class":87,"line":505},[198,1446,1447],{"class":211},"  color",[198,1449,302],{"class":203},[198,1451,1452],{"class":211},"#0f172a",[198,1454,393],{"class":203},[198,1456,1457],{"class":87,"line":531},[198,1458,1367],{"class":203},[198,1460,1461],{"class":87,"line":536},[198,1462,368],{"emptyLinePlaceholder":367},[198,1464,1465],{"class":87,"line":542},[198,1466,1467],{"class":501},"\u002F* Fallback for engines without the safe keyword: auto margins\n",[198,1469,1470],{"class":87,"line":576},[198,1471,1472],{"class":501},"   provide the same start-alignment on overflow. *\u002F\n",[198,1474,1475,1478,1481,1484,1486,1488,1490],{"class":87,"line":581},[198,1476,1477],{"class":308},"@supports",[198,1479,1480],{"class":308}," not",[198,1482,1483],{"class":203}," (",[198,1485,567],{"class":211},[198,1487,1299],{"class":203},[198,1489,526],{"class":211},[198,1491,1492],{"class":203},") {\n",[198,1494,1495,1498,1500,1502,1504,1506,1509],{"class":87,"line":587},[198,1496,1497],{"class":211},"  .overlay",[198,1499,296],{"class":203},[198,1501,521],{"class":211},[198,1503,302],{"class":203},[198,1505,106],{"class":211},[198,1507,1508],{"class":211}," stretch",[198,1510,361],{"class":203},[198,1512,1513,1516,1518,1520,1522,1524],{"class":87,"line":593},[198,1514,1515],{"class":211},"  .overlay__dialog",[198,1517,296],{"class":203},[198,1519,330],{"class":211},[198,1521,302],{"class":203},[198,1523,632],{"class":211},[198,1525,361],{"class":203},[198,1527,1528],{"class":87,"line":599},[198,1529,1367],{"class":203},[14,1531,1532,1533,1535,1536,1538,1539,1541,1542,1546,1547,1550,1551,1555],{},"The ",[37,1534,1477],{}," block is not paranoia. An engine that does not understand ",[37,1537,1133],{}," drops the entire ",[37,1540,521],{}," declaration, not just the keyword, and the dialog would snap to the top-left. With the fallback, those engines get auto-margin centering, which is safe by construction. For entry and exit motion on the dialog itself, ",[18,1543,1545],{"href":1544},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransitioning-display-with-allow-discrete\u002F","Transitioning display With allow-discrete"," shows how to animate a centered element in and out of ",[37,1548,1549],{},"display: none"," without JavaScript, and ",[18,1552,1554],{"href":1553},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fpopover-attribute-and-css-styling\u002F","Popover Attribute and CSS Styling"," covers the top-layer alternative to a custom overlay.",[29,1557,1559],{"id":1558},"browser-support","Browser support",[14,1561,1562,1563,1565,1566,1188,1569,1571,1572,1574,1575,1577,1578,1580,1581,1584],{},"Grid ",[37,1564,521],{}," and flexbox alignment are supported everywhere; CSS Grid dates from Chrome 57, Firefox 52 and Safari 10.1. ",[37,1567,1568],{},"inset",[37,1570,686],{}," sizing are also universal in current engines, with ",[37,1573,686],{}," at Chrome 46, Firefox 94 and Safari 11. The two newer pieces need care. ",[37,1576,176],{}," on block containers shipped across engines only recently, so pair it with a flex or grid fallback if you support older browsers. The ",[37,1579,1133],{}," alignment keyword arrived in Firefox first and in Chromium and Safari later; the ",[37,1582,1583],{},"@supports not (align-items: safe center)"," fallback shown above covers every engine that lacks it.",[29,1586,1588],{"id":1587},"faq","FAQ",[14,1590,1591,1595,1596,1599,1600,1602],{},[1592,1593,1594],"strong",{},"What is the shortest way to center an element both ways?","\nMake the parent ",[37,1597,1598],{},"display: grid"," and add ",[37,1601,153],{},". It works for any single child of unknown size and needs no rules on the child itself.",[14,1604,1605,1608,1609,1611,1612,1614,1615,1617],{},[1592,1606,1607],{},"Why does my centered content get cut off at the top when it is taller than the container?","\nCentering splits overflow equally on both sides, so part of the content moves above the container's start edge where it cannot be scrolled to. Use the ",[37,1610,1133],{}," keyword, as in ",[37,1613,1112],{},", or ",[37,1616,1151],{}," on the child, both of which fall back to start alignment when there is overflow.",[14,1619,1620,1623,1624,1626,1627,1630],{},[1592,1621,1622],{},"Can I center vertically without flexbox or grid now?","\nYes. ",[37,1625,176],{}," now applies to ordinary block containers, so ",[37,1628,1629],{},"align-content: center"," on a block with a set height centers its content vertically without changing its display type. Support is newer than flexbox and grid, so keep a fallback for older engines.",[14,1632,1633,1640,1641,1644,1645,1648,1649,1651],{},[1592,1634,1635,1636,1639],{},"Is ",[37,1637,1638],{},"transform: translate(-50%, -50%)"," still a good centering technique?","\nOnly for absolutely positioned elements whose size you cannot know and when you need them out of flow. It can blur text on fractional pixels and it occupies the ",[37,1642,1643],{},"transform"," property you may want for animation. ",[37,1646,1647],{},"inset: 0"," with ",[37,1650,1151],{}," does the same job without a transform when the element has a size.",[29,1653,1655],{"id":1654},"related","Related",[1657,1658,1659,1665,1672,1679,1686],"ul",{},[1660,1661,1662,1664],"li",{},[18,1663,21],{"href":20}," — the parent guide on flex-driven layout.",[1660,1666,1667,1671],{},[18,1668,1670],{"href":1669},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflexbox-gap-and-spacing\u002F","Flexbox gap and Spacing"," — auto margins used to push items apart rather than center them.",[1660,1673,1674,1678],{},[18,1675,1677],{"href":1676},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fsticky-footer-with-flexbox-and-grid\u002F","Sticky Footer With Flexbox or Grid"," — the other classic free-space layout problem.",[1660,1680,1681,1685],{},[18,1682,1684],{"href":1683},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fmin-max-fit-content-explained\u002F","min-content, max-content and fit-content"," — the sizing keyword that makes out-of-flow centering work.",[1660,1687,1688,1692],{},[18,1689,1691],{"href":1690},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fstarting-style-entry-animations\u002F","Starting-Style Entry Animations"," — animating a centered dialog as it appears.",[285,1694,1695],{},"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 .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":194,"searchDepth":218,"depth":218,"links":1697},[1698,1699,1700,1701,1702,1703,1704,1705],{"id":31,"depth":218,"text":32},{"id":179,"depth":218,"text":180},{"id":1056,"depth":218,"text":1057},{"id":1158,"depth":218,"text":1159},{"id":1230,"depth":218,"text":1231},{"id":1558,"depth":218,"text":1559},{"id":1587,"depth":218,"text":1588},{"id":1654,"depth":218,"text":1655},"Center anything in CSS with grid place-items, flexbox, auto margins, align-content on blocks and inset with margin auto, plus the overflow trap safe fixes.","md",{"pageTitle":1709,"datePublished":1710,"dateModified":1710,"faq":1711},"Centering in CSS: Every Modern Method","2026-09-18",[1712,1714,1716,1718],{"q":1594,"a":1713},"Make the parent display: grid and add place-items: center. It works for any single child of unknown size and needs no rules on the child itself.",{"q":1607,"a":1715},"Centering splits overflow equally on both sides, so part of the content moves above the container's start edge where it cannot be scrolled to. Use the safe keyword, as in align-items: safe center, or margin: auto on the child, both of which fall back to start alignment when there is overflow.",{"q":1622,"a":1717},"Yes. align-content now applies to ordinary block containers, so align-content: center on a block with a set height centers its content vertically without changing its display type. Support is newer than flexbox and grid, so keep a fallback for older engines.",{"q":1719,"a":1720},"Is transform: translate(-50%, -50%) still a good centering technique?","Only for absolutely positioned elements whose size you cannot know and when you need them out of flow. It can blur text on fractional pixels and it occupies the transform property you may want for animation. inset: 0 with margin: auto does the same job without a transform when the element has a size.","\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fcentering-in-css-every-method",{"title":5,"description":1706},"mastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fcentering-in-css-every-method\u002Findex","gtElodJ4qXaI9XhUCXINUQIu30OnyCqMo73mr_k3Sgc",[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,1891,1894,1897,1900,1903,1906,1909,1912,1915,1918,1921,1924,1927,1930,1933,1936,1939,1942,1945,1948,1951,1954,1957,1960,1963,1966,1969,1972,1975,1978,1981,1984,1987,1990,1993,1996,1999,2002,2005,2007,2010,2013,2016,2019,2022,2025,2028,2031,2034,2037,2040,2043,2046,2049,2052,2055,2058,2061,2064,2067,2070,2073,2076,2079,2082,2085,2088,2091,2094,2097,2100,2101,2104,2107,2110,2113,2116,2119,2122,2125,2128,2131,2134,2137,2140,2143,2145,2148,2151,2154,2157,2160,2163,2166,2169,2172,2175,2178,2181,2184,2187,2190,2193,2196,2199,2202,2205,2208,2211,2214,2217,2220,2223,2226,2229,2232,2235,2238,2241,2244,2247,2250,2253,2256,2259,2262,2265,2268,2271,2274,2277,2280],{"path":1727,"title":1728},"\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":1730,"title":1731},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fflashing-content-and-seizure-thresholds","Flashing Content and Seizure Thresholds",{"path":1733,"title":1734},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fforced-colors-mode-and-animations","Forced Colors Mode and Animations",{"path":1736,"title":1737},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations","Accessibility in CSS Animations: Patterns, Specs & Best Practices",{"path":1739,"title":1740},"\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":1742,"title":1743},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fprefers-reduced-motion-recipes","prefers-reduced-motion Recipes: A Reduction for Every Common Effect",{"path":1745,"title":1746},"\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":1748,"title":1749},"\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":1751,"title":1752},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fvestibular-safe-animation-patterns","Vestibular-Safe Animation Patterns: Why Some Motion Makes People Sick",{"path":1754,"title":1755},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fwcag-motion-success-criteria","WCAG Motion Success Criteria: What Each One Actually Requires",{"path":1757,"title":1758},"\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":1760,"title":1761},"\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":1763,"title":1764},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations","Clip-Path & Mask Animations: Animating Visibility Instead of Position",{"path":1766,"title":1767},"\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":1769,"title":1770},"\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":1772,"title":1773},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fanimating-gradients","Animating CSS Gradients: Smooth Colour Motion Without Jumps",{"path":1775,"title":1776},"\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":1778,"title":1779},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions","Color & Theme Transitions: Colour as Part of the Motion System",{"path":1781,"title":1782},"\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":1784,"title":1785},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fsmooth-theme-switching-transitions","Smooth Theme Switching: Crossfades, Circular Reveals and No Flash",{"path":1787,"title":1788},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fcontainer-query-hover-affordances","Container Query Hover Affordances: When Narrow Means Persistent, Not Hidden",{"path":1790,"title":1791},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion","Container-Aware Motion: Animation Sized by the Space a Component Actually Has",{"path":1793,"title":1794},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Flayout-change-animations-at-container-breakpoints","Animating Changes at Container Breakpoints",{"path":1796,"title":1797},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fmotion-driven-by-container-style-queries","Motion Driven by Container Style Queries",{"path":1799,"title":1800},"\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":1802,"title":1803},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fsuppressing-motion-in-small-containers","Suppressing Motion in Small Containers: Deliberately Animating Nothing",{"path":1805,"title":1806},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fcontrolling-css-animations-from-javascript","Controlling CSS Animations From JavaScript",{"path":1808,"title":1809},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api","CSS Animation vs the Web Animations API: A Decision Guide",{"path":1811,"title":1812},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fwaapi-vs-css-for-interruptible-ui","Interruptible UI: CSS Transitions vs WAAPI",{"path":1814,"title":1815},"\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":1817,"title":1818},"\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":1820,"title":1821},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fcustom-property-fallbacks-and-invalid-values","Custom Property Fallbacks and Invalid Values",{"path":1823,"title":1824},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Ffluid-spacing-tokens-driving-transition-durations","Fluid Spacing Tokens That Drive Transition Durations",{"path":1826,"title":1827},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture","CSS Custom Properties Architecture: Scalable Design Systems & Dynamic UI",{"path":1829,"title":1830},"\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":1832,"title":1833},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fscoping-custom-properties-to-components","Scoping Custom Properties to Components",{"path":1835,"title":1836},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fcss-transition-timing-functions","CSS Transition Timing Functions: ease, cubic-bezier(), steps() and linear()",{"path":1838,"title":1839},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals","CSS Transition Fundamentals: Architecture, Performance & Patterns",{"path":1841,"title":1842},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Finterrupted-and-reversing-transitions","Interrupted and Reversing Transitions: What Happens Mid-Flight",{"path":1844,"title":1845},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fstarting-style-entry-animations","@starting-style: Animating an Element's Very First Style Change",{"path":1847,"title":1848},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransition-delay-choreography","Choreographing Motion With transition-delay",{"path":1850,"title":1851},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransition-shorthand-and-multiple-properties","The transition Shorthand and Multiple Properties",{"path":1853,"title":1854},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransitioning-display-with-allow-discrete","Transitioning display with transition-behavior: allow-discrete and @starting-style",{"path":1856,"title":1857},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fanimating-dialog-open-and-close","Animating \u003Cdialog> Open and Close: Both Directions, No Library",{"path":1859,"title":1860},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fbackdrop-animations","Animating ::backdrop: Fades and Blurs Behind Dialogs and Popovers",{"path":1862,"title":1863},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations","Dialog & Popover Animations: Motion for the Top Layer",{"path":1865,"title":1866},"\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":1868,"title":1869},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fpopover-entry-and-exit-transitions","Popover Menus That Animate From Their Anchor",{"path":1871,"title":1872},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fchoosing-animation-durations","Choosing Animation Durations: How Long Motion Should Last",{"path":1874,"title":1875},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fcubic-bezier-overshoot-and-anticipation","Overshoot and Anticipation With cubic-bezier(): Motion With Character",{"path":1877,"title":1878},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fentry-vs-exit-easing","Entry vs Exit Easing: Different Curves for Arriving and Leaving",{"path":1880,"title":1881},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design","Easing & Motion Design: Making CSS Motion Feel Intentional",{"path":1883,"title":1884},"\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":1886,"title":1887},"\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":1889,"title":1890},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Faccessible-css-only-tooltips","Accessible CSS-Only Tooltips and Hover Cards With  and ",{"path":1892,"title":1893},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fbutton-press-and-active-states","Button Press and  States",{"path":1895,"title":1896},"\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":1898,"title":1899},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Ffocus-within-form-patterns"," Form Patterns: Styling a Group From the Field Inside It",{"path":1901,"title":1902},"\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":1904,"title":1905},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design","Hover & Focus State Design: Spec-Compliant Patterns for Modern UIs",{"path":1907,"title":1908},"\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":1910,"title":1911},"\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":1913,"title":1914},"\u002Fcss-only-micro-interactions-animations","CSS-Only Micro-Interactions & Animations: Architecture, Performance & Implementation",{"path":1916,"title":1917},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fanimation-composition-and-stacking","Stacking Animations With animation-composition",{"path":1919,"title":1920},"\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":1922,"title":1923},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcontainer-query-triggered-keyframe-animations","Container-Query-Triggered Keyframe Animations: Animate Differently per Available Space",{"path":1925,"title":1926},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcss-only-accordions-and-disclosure","CSS-Only Accordions and Disclosure Widgets with details and summary",{"path":1928,"title":1929},"\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":1931,"title":1932},"\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":1934,"title":1935},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns","Keyframe Animation Patterns: Spec-Compliant Architectures for Modern UIs",{"path":1937,"title":1938},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fmulti-step-keyframes-and-per-keyframe-easing","Multi-Step Keyframes and Per-Keyframe Easing",{"path":1940,"title":1941},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fstaggered-list-animations-with-custom-properties","Staggered List Animations Using --i Index Custom Properties",{"path":1943,"title":1944},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fanimating-box-shadow-and-filters-cheaply","Animating box-shadow and Filters Cheaply",{"path":1946,"title":1947},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fcontain-property-for-animation-performance","The contain Property for Animation Performance",{"path":1949,"title":1950},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fcss-triggers-layout-paint-composite","Layout, Paint and Composite: What Triggers What",{"path":1952,"title":1953},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration","Performance & GPU Acceleration in CSS: A Developer’s Blueprint",{"path":1955,"title":1956},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Foptimizing-css-animations-for-60fps","Optimizing CSS Animations for 60fps: Budgeting the Frame",{"path":1958,"title":1959},"\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":1961,"title":1962},"\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":1964,"title":1965},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations","Scroll-Driven Animations: Binding Motion to Scroll Position in Pure CSS",{"path":1967,"title":1968},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-driven-animation-fallbacks","Shipping Scroll-Driven Animations Without Breaking Anything",{"path":1970,"title":1971},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-driven-parallax-effects","Scroll-Driven Parallax Effects in CSS",{"path":1973,"title":1974},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-progress-bar-without-javascript","A Reading Progress Bar Driven by scroll(root)",{"path":1976,"title":1977},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-triggered-reveal-animations","Reveal-on-Scroll with view() and animation-range",{"path":1979,"title":1980},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Ftimeline-scope-for-cross-element-animations","timeline-scope for Cross-Element Animations",{"path":1982,"title":1983},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fview-timeline-and-animation-range","View Timelines and animation-range",{"path":1985,"title":1986},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fcross-document-view-transitions","Cross-Document View Transitions",{"path":1988,"title":1989},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers","View Transitions for CSS Developers: the Pseudo-Element Tree, Snapshots, and Named Elements",{"path":1991,"title":1992},"\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":1994,"title":1995},"\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":1997,"title":1998},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transition-types-and-classes","View Transition Types and Classes",{"path":2000,"title":2001},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transitions-for-list-reordering","View Transitions for List Reordering",{"path":2003,"title":2004},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transitions-with-reduced-motion","Honouring prefers-reduced-motion in View Transitions",{"path":312,"title":2006},"Modern CSS Layouts & Micro-Interactions",{"path":2008,"title":2009},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-positioned-tooltips","Anchor-Positioned Tooltips: Tethering, Flipping, and Getting the Semantics Right",{"path":2011,"title":2012},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-positioning-fallbacks","Anchor Positioning Fallbacks: A Graceful Floor for Older Browser Versions",{"path":2014,"title":2015},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-size-for-matching-widths","anchor-size(): Overlays That Match Their Trigger's Size",{"path":2017,"title":2018},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays","CSS Anchor Positioning and Overlays: Tethering Elements Without JavaScript",{"path":2020,"title":2021},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fpopover-attribute-and-css-styling","The popover Attribute: Top-Layer Overlays With No JavaScript",{"path":2023,"title":2024},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fpopover-light-dismiss-and-stacking","Popover Light Dismiss, Nesting and Stacking",{"path":2026,"title":2027},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fposition-area-grid-explained","position-area: The Anchor Placement Grid",{"path":2029,"title":2030},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fcontainer-query-polyfill-tradeoffs","Container Query Polyfills: What They Cost and When to Skip Them",{"path":2032,"title":2033},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Ffeature-detection-with-supports","Feature Detection with @supports: Syntax, Semantics, and the Traps",{"path":2035,"title":2036},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fhandling-container-query-fallbacks-for-older-browsers","Handling Container Query Fallbacks for Older Browsers",{"path":2038,"title":2039},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks","Container Query Fallbacks: Spec-Compliant CSS Strategies for Legacy Browsers",{"path":2041,"title":2042},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fintrinsic-layout-fallbacks-without-queries","Intrinsic Layout Fallbacks: Baselines That Adapt Without Any Query",{"path":2044,"title":2045},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Ftesting-fallbacks-without-old-browsers","Testing CSS Fallbacks Without an Old Browser",{"path":2047,"title":2048},"\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":2050,"title":2051},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-query-range-and-logic-operators","Container Query Range Syntax and Logic Operators",{"path":2053,"title":2054},"\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":2056,"title":2057},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-type-size-vs-inline-size","Choosing container-type: inline-size, size, or normal",{"path":2059,"title":2060},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-vs-media-queries-comparison","Container vs Media Queries: Choosing the Right Reference Box",{"path":2062,"title":2063},"\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":2065,"title":2066},"\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":2068,"title":2069},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics","Container Query Syntax Basics",{"path":2071,"title":2072},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fnesting-and-naming-container-queries","Nesting and Naming Container Queries: Targeting the Right Ancestor",{"path":2074,"title":2075},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fauto-fit-minmax-responsive-grids","Responsive Grids with repeat(auto-fit, minmax())",{"path":2077,"title":2078},"\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":2080,"title":2081},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fgrid-auto-flow-dense-packing","grid-auto-flow: dense for Packed Layouts",{"path":2083,"title":2084},"\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":2086,"title":2087},"\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":2089,"title":2090},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts","CSS Grid and Subgrid Layouts for Responsive Interfaces",{"path":2092,"title":2093},"\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":2095,"title":2096},"\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":2098,"title":2099},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fsubgrid-vs-nested-grid","Subgrid vs an Independently Nested Grid",{"path":1721,"title":5},{"path":2102,"title":2103},"\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":2105,"title":2106},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-grow-and-flex-shrink-explained","flex-grow and flex-shrink Explained",{"path":2108,"title":2109},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-wrap-intrinsic-responsive-rows","Breakpoint-Free Responsive Rows With flex-wrap and flex-basis",{"path":2111,"title":2112},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflexbox-gap-and-spacing","Flexbox gap vs Margins: Spacing Items Without Edge Hacks",{"path":2114,"title":2115},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns","Flexbox Layout Patterns: One-Dimensional Layout for Real Components",{"path":2117,"title":2118},"\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":2120,"title":2121},"\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":2123,"title":2124},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Fdebugging-clamp-values","Debugging clamp(): Values That Are Ignored, Stuck or Never Fluid",{"path":2126,"title":2127},"\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":2129,"title":2130},"\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":2132,"title":2133},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-type-accessibility-and-zoom","Fluid Type, Accessibility and Zoom: The vw-Only Trap",{"path":2135,"title":2136},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-typography-without-javascript","Fluid Typography Without JavaScript: A Precision CSS Reference",{"path":2138,"title":2139},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp","Fluid Typography with clamp(): A Practical Guide for Modern CSS",{"path":2141,"title":2142},"\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":2144,"title":26},"\u002Fmastering-container-queries-responsive-layouts",{"path":2146,"title":2147},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Faspect-ratio-for-responsive-media","Using aspect-ratio for Responsive Media and Preventing Layout Shift",{"path":2149,"title":2150},"\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":2152,"title":2153},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques","Intrinsic Sizing Techniques: Modern CSS Layouts for Responsive UI",{"path":2155,"title":2156},"\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":2158,"title":2159},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fmin-max-fit-content-explained","min-content, max-content, and fit-content() Explained",{"path":2161,"title":2162},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fobject-fit-and-object-position","object-fit and object-position: Images That Fit Any Box",{"path":2164,"title":2165},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fpreventing-flex-and-grid-overflow","The min-width: auto Trap in Flex and Grid Layouts",{"path":2167,"title":2168},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcascade-layers-for-reset-and-tokens","Cascade Layers for Reset and Design Tokens",{"path":2170,"title":2171},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcascade-layers-vs-specificity-hacks","Cascade Layers vs Specificity Hacks: Ordering Instead of Escalating",{"path":2173,"title":2174},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcss-scope-for-component-styles","@scope for Component Styles: Short Selectors That Cannot Leak",{"path":2176,"title":2177},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies","Modern CSS Reset Strategies: A Spec-Compliant Foundation",{"path":2179,"title":2180},"\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":2182,"title":2183},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fwriting-a-minimal-modern-reset","Writing a Minimal Modern CSS Reset: Every Line Justified",{"path":2185,"title":2186},"\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":2188,"title":2189},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fempty-and-loading-states-with-has","Empty and Loading States With ()",{"path":2191,"title":2192},"\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":2194,"title":2195},"\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":2197,"title":2198},"\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":2200,"title":2201},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has","Parent-Aware Layouts With :has(): Letting Containers React to Their Contents",{"path":2203,"title":2204},"\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":2206,"title":2207},"\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":2209,"title":2210},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fcontainer-query-data-tables","Container Query Data Tables: Reflowing Tables to Cards",{"path":2212,"title":2213},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fcontainer-query-sidebar-layouts","Container Query Sidebar Layouts That Travel Between Contexts",{"path":2215,"title":2216},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns","Responsive Component Patterns: Architecture & Implementation",{"path":2218,"title":2219},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-forms-with-container-queries","Responsive Forms with Container Queries: Reflow Without Losing the Wiring",{"path":2221,"title":2222},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-hero-sections-with-container-queries","Responsive Hero Sections With Container Queries",{"path":2224,"title":2225},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-navigation-without-media-queries","Responsive Navigation Without Media Queries Using Container Queries",{"path":2227,"title":2228},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-pricing-tables","Responsive Pricing Tables: Aligned Features, a Clear Recommendation, Any Width",{"path":2230,"title":2231},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Ftabs-that-become-accordions","Tabs That Become an Accordion: One Component, Two Layouts",{"path":2233,"title":2234},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Fcss-only-carousel-with-scroll-snap","A CSS-Only Carousel With Scroll Snap",{"path":2236,"title":2237},"\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":2239,"title":2240},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts","Scroll Snap & Overflow Layouts: Designing Components That Scroll on Purpose",{"path":2242,"title":2243},"\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":2245,"title":2246},"\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":2248,"title":2249},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fcombining-size-and-style-queries","Combining Size and Style Container Queries",{"path":2251,"title":2252},"\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":2254,"title":2255},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state","Style Queries and Container State: Token-Driven Component Variants",{"path":2257,"title":2258},"\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":2260,"title":2261},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fstyle-query-component-variants","Component Variants With Style Queries: One Token, Many Looks",{"path":2263,"title":2264},"\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":2266,"title":2267},"\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":2269,"title":2270},"\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":2272,"title":2273},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout","Viewport Units & Mobile Layout: Designing for the Screen You Actually Get",{"path":2275,"title":2276},"\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":2278,"title":2279},"\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":2281,"title":2282},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fvirtual-keyboard-and-interactive-widget","Layouts That Survive the Virtual Keyboard",{"title":2284,"caption":2285,"height":2286,"html":2287,"css":2288},"Five centering methods side by side","Each dashed box centers its label a different way; all five land in the same place when the label fits.",560,"\n\u003Cdiv class=\"box grid-center\">\u003Cspan class=\"item\">1 · grid\u003C\u002Fspan>\u003C\u002Fdiv>\n\u003Cdiv class=\"box flex-center\">\u003Cspan class=\"item\">2 · flex\u003C\u002Fspan>\u003C\u002Fdiv>\n\u003Cdiv class=\"box margin-center\">\u003Cspan class=\"item\">3 · auto margins\u003C\u002Fspan>\u003C\u002Fdiv>\n\u003Cdiv class=\"box block-center\">\u003Cdiv class=\"item\">4 · block align-content\u003C\u002Fdiv>\u003C\u002Fdiv>\n\u003Cdiv class=\"box abs-parent\">\u003Cspan class=\"item\">5 · inset + margin\u003C\u002Fspan>\u003C\u002Fdiv>","\nbody { display: grid; place-items: stretch; gap: 1rem; font-size: 14px; }\n.box {\n  height: 5rem;\n  border: 1px dashed var(--demo-border);\n  border-radius: 8px;\n}\n.item { padding: 0.5rem 0.75rem; border-radius: 6px; background: var(--demo-surface); border: 1px solid var(--demo-accent); }\n.grid-center { display: grid; place-items: center; }\n.flex-center { display: flex; justify-content: center; align-items: center; }\n.margin-center { display: flex; }\n.margin-center > .item { margin: auto; }\n.block-center { align-content: center; }\n.block-center > .item { width: fit-content; margin-inline: auto; }\n.abs-parent { position: relative; }\n.abs-parent > .item {\n  position: absolute;\n  inset: 0;\n  width: fit-content;\n  height: fit-content;\n  margin: auto;\n}",1789717747882]