[{"data":1,"prerenderedAt":2477},["ShallowReactive",2],{"page-\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fcontrolling-css-animations-from-javascript":3,"content-all-pages":1912,"live-demo:has-pause-loader":2471},{"id":4,"title":5,"body":6,"description":1895,"extension":1896,"meta":1897,"navigation":395,"path":1908,"seo":1909,"stem":1910,"__hash__":1911},"content\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fcontrolling-css-animations-from-javascript\u002Findex.md","Controlling CSS Animations From JavaScript",{"type":7,"value":8,"toc":1881},"minimark",[9,13,42,47,100,207,211,214,1344,1354,1358,1373,1377,1384,1428,1448,1452,1488,1515,1519,1544,1548,1553,1640,1653,1657,1668,1672,1682,1725,1729,1740,1744,1765,1769,1790,1808,1827,1844,1848,1878],[10,11,5],"h1",{"id":12},"controlling-css-animations-from-javascript",[14,15,16,17,21,22,25,26,30,31,36,37,41],"p",{},"The choice between CSS animations and the Web Animations API is often presented as either-or: declare motion in stylesheets, or build it in script. In practice the best split is usually both. Keyframes, durations and easing live in CSS, where designers can read them and media queries can adjust them; script controls ",[18,19,20],"em",{},"when"," and ",[18,23,24],{},"how"," the animation plays — pausing it, seeking to a point, reversing it, waiting for it to end. The bridge between the two is ",[27,28,29],"code",{},"element.getAnimations()",", which returns every running CSS animation and transition as a live object with the full Web Animations API. This page covers that bridge, the events and promises for sequencing, and the right way to restart a keyframe animation. It belongs to ",[32,33,35],"a",{"href":34},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002F","CSS Animation vs Web Animations API"," in the ",[32,38,40],{"href":39},"\u002Fcss-only-micro-interactions-animations\u002F","CSS-Only Micro-Interactions & Animations"," guide.",[43,44,46],"h2",{"id":45},"css-animations-are-animation-objects","CSS animations are Animation objects",[14,48,49,50,53,54,57,58,61,62,65,66,69,70,69,73,69,76,69,79,69,82,69,85,88,89,92,93,95,96,99],{},"When a CSS rule applies ",[27,51,52],{},"animation-name",", the browser creates a ",[27,55,56],{},"CSSAnimation"," object. Transitions create ",[27,59,60],{},"CSSTransition"," objects. Both extend the ",[27,63,64],{},"Animation"," interface from the Web Animations API, so they have ",[27,67,68],{},"play()",", ",[27,71,72],{},"pause()",[27,74,75],{},"reverse()",[27,77,78],{},"cancel()",[27,80,81],{},"finish()",[27,83,84],{},"currentTime",[27,86,87],{},"playbackRate"," and a ",[27,90,91],{},"finished"," promise. ",[27,94,29],{}," returns those attached to one element; ",[27,97,98],{},"document.getAnimations()"," returns all of them on the page.",[101,102,108,109,108,113,108,117,108,125,108,136,108,145,108,149,108,155,108,160,108,164,108,168,108,172,108,176,108,181,108,185,108,188,108,191,108,193,108,195,108,200,108,203],"svg",{"viewBox":103,"role":104,"ariaLabel":105,"xmlns":106,"style":107},"0 0 720 300","img","A CSS rule creates a CSSAnimation object; JavaScript reaches it through getAnimations and controls playback, while keyframes and timing remain defined in CSS","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","width:100%;height:auto;max-width:720px;margin:2rem 0","\n  ",[110,111,112],"title",{},"CSS declares, script controls",[114,115,116],"desc",{},"Left, a CSS box containing keyframes, duration and easing. An arrow leads to a central object labelled CSSAnimation. Right, a JavaScript box with getAnimations, pause, currentTime, playbackRate and finished. Arrows from the JavaScript box act on the object. The keyframes stay owned by CSS.",[118,119,124],"text",{"textAnchor":120,"x":121,"y":122,"style":123},"middle","360","26","text-anchor:middle;fill:currentColor;font:700 17px sans-serif","One animation, two owners",[126,127],"rect",{"x":128,"y":129,"width":130,"height":131,"rx":132,"fill":133,"opacity":134,"stroke":133,"strokeWidth":135},"30","60","200","170","10","#7aa2ff","0.2","1.5",[126,137],{"x":138,"y":139,"width":140,"height":141,"rx":132,"fill":142,"stroke":143,"strokeWidth":144},"270","110","180","70","none","currentColor","2",[126,146],{"x":147,"y":129,"width":130,"height":131,"rx":132,"fill":143,"opacity":148},"490","0.1",[118,150,154],{"textAnchor":120,"x":151,"y":152,"style":153},"130","88","text-anchor:middle;fill:currentColor;font:600 14px sans-serif","CSS",[118,156,159],{"textAnchor":120,"x":151,"y":157,"style":158},"120","text-anchor:middle;fill:currentColor;font:12px ui-monospace,monospace","@keyframes",[118,161,163],{"textAnchor":120,"x":151,"y":162,"style":158},"146","duration, easing",[118,165,167],{"textAnchor":120,"x":151,"y":166,"style":158},"172","reduced-motion",[118,169,171],{"textAnchor":120,"x":151,"y":170,"style":158},"198","overrides",[118,173,56],{"textAnchor":120,"x":121,"y":174,"style":175},"142","text-anchor:middle;fill:currentColor;font:600 14px ui-monospace,monospace",[118,177,180],{"textAnchor":120,"x":121,"y":178,"style":179},"164","text-anchor:middle;fill:currentColor;font:11px sans-serif","live object",[118,182,184],{"textAnchor":120,"x":183,"y":152,"style":153},"590","JavaScript",[118,186,187],{"textAnchor":120,"x":183,"y":157,"style":158},"getAnimations()",[118,189,190],{"textAnchor":120,"x":183,"y":162,"style":158},"pause(), reverse()",[118,192,84],{"textAnchor":120,"x":183,"y":166,"style":158},[118,194,91],{"textAnchor":120,"x":183,"y":170,"style":158},[196,197],"line",{"x1":198,"y1":199,"x2":138,"y2":199,"stroke":143,"strokeWidth":144},"230","145",[196,201],{"x1":147,"y1":199,"x2":202,"y2":199,"stroke":143,"strokeWidth":144},"450",[118,204,206],{"textAnchor":120,"x":121,"y":138,"style":205},"text-anchor:middle;fill:currentColor;font:12px sans-serif","Change the CSS and the object's keyframes change with it.",[43,208,210],{"id":209},"the-complete-implementation","The complete implementation",[14,212,213],{},"A progress bar that animates in CSS, with script controls for pause, resume, scrubbing and waiting for completion.",[215,216,221],"pre",{"className":217,"code":218,"language":219,"meta":220,"style":220},"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>Controlling CSS animations\u003C\u002Ftitle>\n\u003Cstyle>\n  body { font: 15px\u002F1.5 system-ui, sans-serif; margin: 2rem; }\n\n  .loader {\n    inline-size: 12rem;\n    block-size: 0.5rem;\n    border-radius: 999px;\n    background: #e2e8f0;\n    overflow: hidden;\n  }\n  .loader__bar {\n    block-size: 100%;\n    background: #2563eb;\n    transform-origin: left;\n    animation: fill 4s linear forwards;\n  }\n  @keyframes fill { from { scale: 0 1; } to { scale: 1 1; } }\n\n  @media (prefers-reduced-motion: reduce) {\n    .loader__bar { animation-duration: 1ms; }\n  }\n\u003C\u002Fstyle>\n\u003C\u002Fhead>\n\u003Cbody>\n  \u003Cdiv class=\"loader\">\u003Cdiv class=\"loader__bar\">\u003C\u002Fdiv>\u003C\u002Fdiv>\n  \u003Cp>\n    \u003Cbutton type=\"button\" id=\"toggle\">Pause\u003C\u002Fbutton>\n    \u003Cbutton type=\"button\" id=\"restart\">Restart\u003C\u002Fbutton>\n    \u003Cinput type=\"range\" id=\"scrub\" min=\"0\" max=\"1\" step=\"0.01\" value=\"0\" aria-label=\"Scrub\">\n  \u003C\u002Fp>\n  \u003Cp id=\"status\" aria-live=\"polite\">\u003C\u002Fp>\n\n  \u003Cscript>\n    const bar = document.querySelector('.loader__bar');\n    \u002F\u002F The CSS animation, as a Web Animations API object.\n    const [anim] = bar.getAnimations();\n    const duration = anim.effect.getComputedTiming().duration;\n\n    document.getElementById('toggle').addEventListener('click', (e) => {\n      if (anim.playState === 'running') { anim.pause(); e.target.textContent = 'Resume'; }\n      else { anim.play(); e.target.textContent = 'Pause'; }\n    });\n\n    document.getElementById('restart').addEventListener('click', () => {\n      anim.currentTime = 0;\n      anim.play();\n      waitForEnd();\n    });\n\n    document.getElementById('scrub').addEventListener('input', (e) => {\n      anim.pause();\n      anim.currentTime = Number(e.target.value) * duration;\n    });\n\n    async function waitForEnd() {\n      try {\n        await anim.finished;\n        document.getElementById('status').textContent = 'Upload complete';\n      } catch {\n        \u002F\u002F Rejected: the animation was cancelled (for example, the class was removed).\n      }\n    }\n    waitForEnd();\n  \u003C\u002Fscript>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n","html","",[27,222,223,242,262,272,290,315,329,339,390,397,406,422,437,452,465,478,484,492,507,519,532,557,562,610,615,624,644,649,659,668,678,718,727,759,786,849,859,887,892,902,930,937,962,981,986,1025,1056,1077,1083,1088,1115,1128,1138,1146,1151,1156,1187,1196,1215,1220,1225,1240,1248,1257,1280,1291,1297,1303,1309,1317,1326,1335],{"__ignoreMap":220},[224,225,227,231,235,239],"span",{"class":196,"line":226},1,[224,228,230],{"class":229},"suds8","\u003C!",[224,232,234],{"class":233},"sne4z","doctype",[224,236,238],{"class":237},"s-5SL"," html",[224,240,241],{"class":229},">\n",[224,243,245,248,250,253,256,260],{"class":196,"line":244},2,[224,246,247],{"class":229},"\u003C",[224,249,219],{"class":233},[224,251,252],{"class":237}," lang",[224,254,255],{"class":229},"=",[224,257,259],{"class":258},"sT6z2","\"en\"",[224,261,241],{"class":229},[224,263,265,267,270],{"class":196,"line":264},3,[224,266,247],{"class":229},[224,268,269],{"class":233},"head",[224,271,241],{"class":229},[224,273,275,277,280,283,285,288],{"class":196,"line":274},4,[224,276,247],{"class":229},[224,278,279],{"class":233},"meta",[224,281,282],{"class":237}," charset",[224,284,255],{"class":229},[224,286,287],{"class":258},"\"utf-8\"",[224,289,241],{"class":229},[224,291,293,295,297,300,302,305,308,310,313],{"class":196,"line":292},5,[224,294,247],{"class":229},[224,296,279],{"class":233},[224,298,299],{"class":237}," name",[224,301,255],{"class":229},[224,303,304],{"class":258},"\"viewport\"",[224,306,307],{"class":237}," content",[224,309,255],{"class":229},[224,311,312],{"class":258},"\"width=device-width, initial-scale=1\"",[224,314,241],{"class":229},[224,316,318,320,322,325,327],{"class":196,"line":317},6,[224,319,247],{"class":229},[224,321,110],{"class":233},[224,323,324],{"class":229},">Controlling CSS animations\u003C\u002F",[224,326,110],{"class":233},[224,328,241],{"class":229},[224,330,332,334,337],{"class":196,"line":331},7,[224,333,247],{"class":229},[224,335,336],{"class":233},"style",[224,338,241],{"class":229},[224,340,342,345,348,351,354,357,361,364,366,369,371,374,377,380,382,384,387],{"class":196,"line":341},8,[224,343,344],{"class":233},"  body",[224,346,347],{"class":229}," { ",[224,349,350],{"class":237},"font",[224,352,353],{"class":229},": ",[224,355,356],{"class":237},"15",[224,358,360],{"class":359},"sHUrx","px",[224,362,363],{"class":229},"\u002F",[224,365,135],{"class":237},[224,367,368],{"class":237}," system-ui",[224,370,69],{"class":229},[224,372,373],{"class":237},"sans-serif",[224,375,376],{"class":229},"; ",[224,378,379],{"class":237},"margin",[224,381,353],{"class":229},[224,383,144],{"class":237},[224,385,386],{"class":359},"rem",[224,388,389],{"class":229},"; }\n",[224,391,393],{"class":196,"line":392},9,[224,394,396],{"emptyLinePlaceholder":395},true,"\n",[224,398,400,403],{"class":196,"line":399},10,[224,401,402],{"class":237},"  .loader",[224,404,405],{"class":229}," {\n",[224,407,409,412,414,417,419],{"class":196,"line":408},11,[224,410,411],{"class":237},"    inline-size",[224,413,353],{"class":229},[224,415,416],{"class":237},"12",[224,418,386],{"class":359},[224,420,421],{"class":229},";\n",[224,423,425,428,430,433,435],{"class":196,"line":424},12,[224,426,427],{"class":237},"    block-size",[224,429,353],{"class":229},[224,431,432],{"class":237},"0.5",[224,434,386],{"class":359},[224,436,421],{"class":229},[224,438,440,443,445,448,450],{"class":196,"line":439},13,[224,441,442],{"class":237},"    border-radius",[224,444,353],{"class":229},[224,446,447],{"class":237},"999",[224,449,360],{"class":359},[224,451,421],{"class":229},[224,453,455,458,460,463],{"class":196,"line":454},14,[224,456,457],{"class":237},"    background",[224,459,353],{"class":229},[224,461,462],{"class":237},"#e2e8f0",[224,464,421],{"class":229},[224,466,468,471,473,476],{"class":196,"line":467},15,[224,469,470],{"class":237},"    overflow",[224,472,353],{"class":229},[224,474,475],{"class":237},"hidden",[224,477,421],{"class":229},[224,479,481],{"class":196,"line":480},16,[224,482,483],{"class":229},"  }\n",[224,485,487,490],{"class":196,"line":486},17,[224,488,489],{"class":237},"  .loader__bar",[224,491,405],{"class":229},[224,493,495,497,499,502,505],{"class":196,"line":494},18,[224,496,427],{"class":237},[224,498,353],{"class":229},[224,500,501],{"class":237},"100",[224,503,504],{"class":359},"%",[224,506,421],{"class":229},[224,508,510,512,514,517],{"class":196,"line":509},19,[224,511,457],{"class":237},[224,513,353],{"class":229},[224,515,516],{"class":237},"#2563eb",[224,518,421],{"class":229},[224,520,522,525,527,530],{"class":196,"line":521},20,[224,523,524],{"class":237},"    transform-origin",[224,526,353],{"class":229},[224,528,529],{"class":237},"left",[224,531,421],{"class":229},[224,533,535,538,540,543,546,549,552,555],{"class":196,"line":534},21,[224,536,537],{"class":237},"    animation",[224,539,353],{"class":229},[224,541,542],{"class":237},"fill",[224,544,545],{"class":237}," 4",[224,547,548],{"class":359},"s",[224,550,551],{"class":237}," linear",[224,553,554],{"class":237}," forwards",[224,556,421],{"class":229},[224,558,560],{"class":196,"line":559},22,[224,561,483],{"class":229},[224,563,565,568,572,574,577,579,582,584,587,590,593,596,598,600,602,605,607],{"class":196,"line":564},23,[224,566,567],{"class":359},"  @keyframes",[224,569,571],{"class":570},"soyes"," fill",[224,573,347],{"class":229},[224,575,576],{"class":237},"from",[224,578,347],{"class":229},[224,580,581],{"class":237},"scale",[224,583,353],{"class":229},[224,585,586],{"class":237},"0",[224,588,589],{"class":237}," 1",[224,591,592],{"class":229},"; } ",[224,594,595],{"class":237},"to",[224,597,347],{"class":229},[224,599,581],{"class":237},[224,601,353],{"class":229},[224,603,604],{"class":237},"1",[224,606,589],{"class":237},[224,608,609],{"class":229},"; } }\n",[224,611,613],{"class":196,"line":612},24,[224,614,396],{"emptyLinePlaceholder":395},[224,616,618,621],{"class":196,"line":617},25,[224,619,620],{"class":359},"  @media",[224,622,623],{"class":229}," (prefers-reduced-motion: reduce) {\n",[224,625,627,630,632,635,637,639,642],{"class":196,"line":626},26,[224,628,629],{"class":237},"    .loader__bar",[224,631,347],{"class":229},[224,633,634],{"class":237},"animation-duration",[224,636,353],{"class":229},[224,638,604],{"class":237},[224,640,641],{"class":359},"ms",[224,643,389],{"class":229},[224,645,647],{"class":196,"line":646},27,[224,648,483],{"class":229},[224,650,652,655,657],{"class":196,"line":651},28,[224,653,654],{"class":229},"\u003C\u002F",[224,656,336],{"class":233},[224,658,241],{"class":229},[224,660,662,664,666],{"class":196,"line":661},29,[224,663,654],{"class":229},[224,665,269],{"class":233},[224,667,241],{"class":229},[224,669,671,673,676],{"class":196,"line":670},30,[224,672,247],{"class":229},[224,674,675],{"class":233},"body",[224,677,241],{"class":229},[224,679,681,684,687,690,692,695,698,700,702,704,707,710,712,714,716],{"class":196,"line":680},31,[224,682,683],{"class":229},"  \u003C",[224,685,686],{"class":233},"div",[224,688,689],{"class":237}," class",[224,691,255],{"class":229},[224,693,694],{"class":258},"\"loader\"",[224,696,697],{"class":229},">\u003C",[224,699,686],{"class":233},[224,701,689],{"class":237},[224,703,255],{"class":229},[224,705,706],{"class":258},"\"loader__bar\"",[224,708,709],{"class":229},">\u003C\u002F",[224,711,686],{"class":233},[224,713,709],{"class":229},[224,715,686],{"class":233},[224,717,241],{"class":229},[224,719,721,723,725],{"class":196,"line":720},32,[224,722,683],{"class":229},[224,724,14],{"class":233},[224,726,241],{"class":229},[224,728,730,733,736,739,741,744,747,749,752,755,757],{"class":196,"line":729},33,[224,731,732],{"class":229},"    \u003C",[224,734,735],{"class":233},"button",[224,737,738],{"class":237}," type",[224,740,255],{"class":229},[224,742,743],{"class":258},"\"button\"",[224,745,746],{"class":237}," id",[224,748,255],{"class":229},[224,750,751],{"class":258},"\"toggle\"",[224,753,754],{"class":229},">Pause\u003C\u002F",[224,756,735],{"class":233},[224,758,241],{"class":229},[224,760,762,764,766,768,770,772,774,776,779,782,784],{"class":196,"line":761},34,[224,763,732],{"class":229},[224,765,735],{"class":233},[224,767,738],{"class":237},[224,769,255],{"class":229},[224,771,743],{"class":258},[224,773,746],{"class":237},[224,775,255],{"class":229},[224,777,778],{"class":258},"\"restart\"",[224,780,781],{"class":229},">Restart\u003C\u002F",[224,783,735],{"class":233},[224,785,241],{"class":229},[224,787,789,791,794,796,798,801,803,805,808,811,813,816,819,821,824,827,829,832,835,837,839,842,844,847],{"class":196,"line":788},35,[224,790,732],{"class":229},[224,792,793],{"class":233},"input",[224,795,738],{"class":237},[224,797,255],{"class":229},[224,799,800],{"class":258},"\"range\"",[224,802,746],{"class":237},[224,804,255],{"class":229},[224,806,807],{"class":258},"\"scrub\"",[224,809,810],{"class":237}," min",[224,812,255],{"class":229},[224,814,815],{"class":258},"\"0\"",[224,817,818],{"class":237}," max",[224,820,255],{"class":229},[224,822,823],{"class":258},"\"1\"",[224,825,826],{"class":237}," step",[224,828,255],{"class":229},[224,830,831],{"class":258},"\"0.01\"",[224,833,834],{"class":237}," value",[224,836,255],{"class":229},[224,838,815],{"class":258},[224,840,841],{"class":237}," aria-label",[224,843,255],{"class":229},[224,845,846],{"class":258},"\"Scrub\"",[224,848,241],{"class":229},[224,850,852,855,857],{"class":196,"line":851},36,[224,853,854],{"class":229},"  \u003C\u002F",[224,856,14],{"class":233},[224,858,241],{"class":229},[224,860,862,864,866,868,870,873,876,878,881,883,885],{"class":196,"line":861},37,[224,863,683],{"class":229},[224,865,14],{"class":233},[224,867,746],{"class":237},[224,869,255],{"class":229},[224,871,872],{"class":258},"\"status\"",[224,874,875],{"class":237}," aria-live",[224,877,255],{"class":229},[224,879,880],{"class":258},"\"polite\"",[224,882,709],{"class":229},[224,884,14],{"class":233},[224,886,241],{"class":229},[224,888,890],{"class":196,"line":889},38,[224,891,396],{"emptyLinePlaceholder":395},[224,893,895,897,900],{"class":196,"line":894},39,[224,896,683],{"class":229},[224,898,899],{"class":233},"script",[224,901,241],{"class":229},[224,903,905,908,911,914,917,921,924,927],{"class":196,"line":904},40,[224,906,907],{"class":359},"    const",[224,909,910],{"class":237}," bar",[224,912,913],{"class":359}," =",[224,915,916],{"class":229}," document.",[224,918,920],{"class":919},"sKwhi","querySelector",[224,922,923],{"class":229},"(",[224,925,926],{"class":258},"'.loader__bar'",[224,928,929],{"class":229},");\n",[224,931,933],{"class":196,"line":932},41,[224,934,936],{"class":935},"sLBg1","    \u002F\u002F The CSS animation, as a Web Animations API object.\n",[224,938,940,942,945,948,951,953,956,959],{"class":196,"line":939},42,[224,941,907],{"class":359},[224,943,944],{"class":229}," [",[224,946,947],{"class":237},"anim",[224,949,950],{"class":229},"] ",[224,952,255],{"class":359},[224,954,955],{"class":229}," bar.",[224,957,958],{"class":919},"getAnimations",[224,960,961],{"class":229},"();\n",[224,963,965,967,970,972,975,978],{"class":196,"line":964},43,[224,966,907],{"class":359},[224,968,969],{"class":237}," duration",[224,971,913],{"class":359},[224,973,974],{"class":229}," anim.effect.",[224,976,977],{"class":919},"getComputedTiming",[224,979,980],{"class":229},"().duration;\n",[224,982,984],{"class":196,"line":983},44,[224,985,396],{"emptyLinePlaceholder":395},[224,987,989,992,995,997,1000,1003,1006,1008,1011,1014,1017,1020,1023],{"class":196,"line":988},45,[224,990,991],{"class":229},"    document.",[224,993,994],{"class":919},"getElementById",[224,996,923],{"class":229},[224,998,999],{"class":258},"'toggle'",[224,1001,1002],{"class":229},").",[224,1004,1005],{"class":919},"addEventListener",[224,1007,923],{"class":229},[224,1009,1010],{"class":258},"'click'",[224,1012,1013],{"class":229},", (",[224,1015,1016],{"class":570},"e",[224,1018,1019],{"class":229},") ",[224,1021,1022],{"class":359},"=>",[224,1024,405],{"class":229},[224,1026,1028,1031,1034,1037,1040,1043,1046,1049,1051,1054],{"class":196,"line":1027},46,[224,1029,1030],{"class":359},"      if",[224,1032,1033],{"class":229}," (anim.playState ",[224,1035,1036],{"class":359},"===",[224,1038,1039],{"class":258}," 'running'",[224,1041,1042],{"class":229},") { anim.",[224,1044,1045],{"class":919},"pause",[224,1047,1048],{"class":229},"(); e.target.textContent ",[224,1050,255],{"class":359},[224,1052,1053],{"class":258}," 'Resume'",[224,1055,389],{"class":229},[224,1057,1059,1062,1065,1068,1070,1072,1075],{"class":196,"line":1058},47,[224,1060,1061],{"class":359},"      else",[224,1063,1064],{"class":229}," { anim.",[224,1066,1067],{"class":919},"play",[224,1069,1048],{"class":229},[224,1071,255],{"class":359},[224,1073,1074],{"class":258}," 'Pause'",[224,1076,389],{"class":229},[224,1078,1080],{"class":196,"line":1079},48,[224,1081,1082],{"class":229},"    });\n",[224,1084,1086],{"class":196,"line":1085},49,[224,1087,396],{"emptyLinePlaceholder":395},[224,1089,1091,1093,1095,1097,1100,1102,1104,1106,1108,1111,1113],{"class":196,"line":1090},50,[224,1092,991],{"class":229},[224,1094,994],{"class":919},[224,1096,923],{"class":229},[224,1098,1099],{"class":258},"'restart'",[224,1101,1002],{"class":229},[224,1103,1005],{"class":919},[224,1105,923],{"class":229},[224,1107,1010],{"class":258},[224,1109,1110],{"class":229},", () ",[224,1112,1022],{"class":359},[224,1114,405],{"class":229},[224,1116,1118,1121,1123,1126],{"class":196,"line":1117},51,[224,1119,1120],{"class":229},"      anim.currentTime ",[224,1122,255],{"class":359},[224,1124,1125],{"class":237}," 0",[224,1127,421],{"class":229},[224,1129,1131,1134,1136],{"class":196,"line":1130},52,[224,1132,1133],{"class":229},"      anim.",[224,1135,1067],{"class":919},[224,1137,961],{"class":229},[224,1139,1141,1144],{"class":196,"line":1140},53,[224,1142,1143],{"class":919},"      waitForEnd",[224,1145,961],{"class":229},[224,1147,1149],{"class":196,"line":1148},54,[224,1150,1082],{"class":229},[224,1152,1154],{"class":196,"line":1153},55,[224,1155,396],{"emptyLinePlaceholder":395},[224,1157,1159,1161,1163,1165,1168,1170,1172,1174,1177,1179,1181,1183,1185],{"class":196,"line":1158},56,[224,1160,991],{"class":229},[224,1162,994],{"class":919},[224,1164,923],{"class":229},[224,1166,1167],{"class":258},"'scrub'",[224,1169,1002],{"class":229},[224,1171,1005],{"class":919},[224,1173,923],{"class":229},[224,1175,1176],{"class":258},"'input'",[224,1178,1013],{"class":229},[224,1180,1016],{"class":570},[224,1182,1019],{"class":229},[224,1184,1022],{"class":359},[224,1186,405],{"class":229},[224,1188,1190,1192,1194],{"class":196,"line":1189},57,[224,1191,1133],{"class":229},[224,1193,1045],{"class":919},[224,1195,961],{"class":229},[224,1197,1199,1201,1203,1206,1209,1212],{"class":196,"line":1198},58,[224,1200,1120],{"class":229},[224,1202,255],{"class":359},[224,1204,1205],{"class":919}," Number",[224,1207,1208],{"class":229},"(e.target.value) ",[224,1210,1211],{"class":359},"*",[224,1213,1214],{"class":229}," duration;\n",[224,1216,1218],{"class":196,"line":1217},59,[224,1219,1082],{"class":229},[224,1221,1223],{"class":196,"line":1222},60,[224,1224,396],{"emptyLinePlaceholder":395},[224,1226,1228,1231,1234,1237],{"class":196,"line":1227},61,[224,1229,1230],{"class":359},"    async",[224,1232,1233],{"class":359}," function",[224,1235,1236],{"class":919}," waitForEnd",[224,1238,1239],{"class":229},"() {\n",[224,1241,1243,1246],{"class":196,"line":1242},62,[224,1244,1245],{"class":359},"      try",[224,1247,405],{"class":229},[224,1249,1251,1254],{"class":196,"line":1250},63,[224,1252,1253],{"class":359},"        await",[224,1255,1256],{"class":229}," anim.finished;\n",[224,1258,1260,1263,1265,1267,1270,1273,1275,1278],{"class":196,"line":1259},64,[224,1261,1262],{"class":229},"        document.",[224,1264,994],{"class":919},[224,1266,923],{"class":229},[224,1268,1269],{"class":258},"'status'",[224,1271,1272],{"class":229},").textContent ",[224,1274,255],{"class":359},[224,1276,1277],{"class":258}," 'Upload complete'",[224,1279,421],{"class":229},[224,1281,1283,1286,1289],{"class":196,"line":1282},65,[224,1284,1285],{"class":229},"      } ",[224,1287,1288],{"class":359},"catch",[224,1290,405],{"class":229},[224,1292,1294],{"class":196,"line":1293},66,[224,1295,1296],{"class":935},"        \u002F\u002F Rejected: the animation was cancelled (for example, the class was removed).\n",[224,1298,1300],{"class":196,"line":1299},67,[224,1301,1302],{"class":229},"      }\n",[224,1304,1306],{"class":196,"line":1305},68,[224,1307,1308],{"class":229},"    }\n",[224,1310,1312,1315],{"class":196,"line":1311},69,[224,1313,1314],{"class":919},"    waitForEnd",[224,1316,961],{"class":229},[224,1318,1320,1322,1324],{"class":196,"line":1319},70,[224,1321,854],{"class":229},[224,1323,899],{"class":233},[224,1325,241],{"class":229},[224,1327,1329,1331,1333],{"class":196,"line":1328},71,[224,1330,654],{"class":229},[224,1332,675],{"class":233},[224,1334,241],{"class":229},[224,1336,1338,1340,1342],{"class":196,"line":1337},72,[224,1339,654],{"class":229},[224,1341,219],{"class":233},[224,1343,241],{"class":229},[14,1345,1346,1347,69,1350,1353],{},"The script never mentions ",[27,1348,1349],{},"4s",[27,1351,1352],{},"linear"," or the keyframes. It reads the duration from the object's computed timing, so if a designer changes the CSS — or the reduced-motion query shortens the duration to a millisecond — the controls keep working. That separation is the main benefit of controlling CSS animations rather than recreating them in script. It also means the page still animates if the script fails to load: the CSS plays on its own, and only the extra controls are missing, which is a sensible way to degrade.",[43,1355,1357],{"id":1356},"reading-progress","Reading progress",[14,1359,1360,1361,1364,1365,1368,1369,1372],{},"The object also answers questions CSS cannot. ",[27,1362,1363],{},"anim.effect.getComputedTiming().progress"," returns a number between 0 and 1 for the current iteration, and ",[27,1366,1367],{},"currentIteration"," reports which loop a repeating animation is on. That makes it possible to synchronise something non-visual with a CSS animation — announcing \"halfway\" in a live region, or starting a sound at a keyframe — without duplicating the timing in script. Read these values inside a ",[27,1370,1371],{},"requestAnimationFrame"," callback rather than on a timer, so they line up with rendered frames.",[43,1374,1376],{"id":1375},"the-key-technique-restart-through-the-object-not-the-class","The key technique: restart through the object, not the class",[14,1378,1379,1380,1383],{},"The most common script-and-CSS bug is the restart that does nothing. Removing a class and immediately re-adding it happens within one task; the browser never computes a style without the class, so the animation never stops and never restarts. The old workaround was to force a style flush between the two steps (reading ",[27,1381,1382],{},"offsetWidth","), which works but costs a synchronous layout.",[101,1385,108,1388,108,1391,108,1394,108,1397,108,1403,108,1405,108,1411,108,1416,108,1421,108,1424],{"viewBox":1386,"role":104,"ariaLabel":1387,"xmlns":106,"style":107},"0 0 720 260","Comparison: toggling a class off and on within one frame leaves the animation untouched; calling cancel then play, or setting currentTime to 0, restarts it",[110,1389,1390],{},"Why the class toggle fails",[114,1392,1393],{},"Top row: remove class and add class in the same frame; the next style calculation sees the class present both before and after, so nothing changes and the animation continues. Bottom row: animation.currentTime = 0 or cancel then play acts on the running object directly, so the animation restarts on the next frame without forcing layout.",[118,1395,1396],{"textAnchor":120,"x":121,"y":122,"style":123},"Restarting keyframes",[126,1398],{"x":1399,"y":1400,"width":1401,"height":141,"rx":132,"fill":143,"opacity":1402},"40","56","640","0.08",[126,1404],{"x":1399,"y":162,"width":1401,"height":141,"rx":132,"fill":133,"opacity":134},[118,1406,1410],{"textAnchor":1407,"x":129,"y":1408,"style":1409},"start","84","text-anchor:start;fill:currentColor;font:600 13px sans-serif","classList.remove + add, same frame",[118,1412,1415],{"textAnchor":1407,"x":129,"y":1413,"style":1414},"108","text-anchor:start;fill:currentColor;font:12px sans-serif","style never sees the gap: animation keeps running, no restart",[118,1417,1420],{"textAnchor":1407,"x":129,"y":1418,"style":1419},"174","text-anchor:start;fill:currentColor;font:600 13px ui-monospace,monospace","anim.currentTime = 0; anim.play()",[118,1422,1423],{"textAnchor":1407,"x":129,"y":170,"style":1414},"acts on the live object: restarts next frame, no forced layout",[118,1425,1427],{"textAnchor":120,"x":121,"y":1426,"style":205},"246","For an animation that already finished, currentTime = 0 plus play() replays it.",[14,1429,1430,1431,1434,1435,1437,1438,1441,1442,1444,1445,1447],{},"With the object in hand, restarting is explicit: set ",[27,1432,1433],{},"currentTime = 0"," and call ",[27,1436,68],{},". If the animation has finished and is holding its end state with ",[27,1439,1440],{},"forwards",", the same two lines replay it. If you want the element to snap back to its unanimated style first, call ",[27,1443,78],{}," before ",[27,1446,68],{},".",[43,1449,1451],{"id":1450},"events-versus-the-finished-promise","Events versus the finished promise",[14,1453,1454,1455,69,1458,69,1461,21,1464,1467,1468,69,1471,69,1474,21,1477,1480,1481,21,1484,1487],{},"CSS animations dispatch ",[27,1456,1457],{},"animationstart",[27,1459,1460],{},"animationiteration",[27,1462,1463],{},"animationend",[27,1465,1466],{},"animationcancel"," events; transitions dispatch ",[27,1469,1470],{},"transitionrun",[27,1472,1473],{},"transitionstart",[27,1475,1476],{},"transitionend",[27,1478,1479],{},"transitioncancel",". Events bubble, which is useful for delegation — one listener on a list can react to every item's animation — but it also means a child's animation end can trigger a parent's handler unexpectedly. Check ",[27,1482,1483],{},"event.target",[27,1485,1486],{},"event.animationName"," before acting.",[14,1489,1490,1491,1493,1494,1497,1498,1501,1502,1505,1506,1508,1509,363,1512,1514],{},"The ",[27,1492,91],{}," promise is scoped to one animation and composes with ",[27,1495,1496],{},"async"," code: ",[27,1499,1500],{},"await Promise.all(el.getAnimations().map((a) => a.finished))"," waits for every animation and transition on an element, which is exactly what you need before removing an element after its exit animation. Remember that the promise rejects when the animation is cancelled — by removing the class, setting ",[27,1503,1504],{},"display: none",", or changing ",[27,1507,52],{}," — so wrap it in ",[27,1510,1511],{},"try",[27,1513,1288],{}," or attach a rejection handler.",[43,1516,1518],{"id":1517},"script-play-state-overrides-css-play-state","Script play state overrides CSS play state",[14,1520,1521,1522,1524,1525,1527,1528,1530,1531,1534,1535,1537,1538,1541,1542,1447],{},"Calling ",[27,1523,72],{}," or ",[27,1526,68],{}," on a ",[27,1529,56],{}," has a lasting side effect: from then on, the animation ignores ",[27,1532,1533],{},"animation-play-state"," from the stylesheet. The specification treats the script call as an explicit instruction that takes precedence. In practice this means mixing the two control styles on the same animation produces confusing results — a CSS pause toggle stops working once any script has called ",[27,1536,68],{},". Pick one owner for playback per animation. If a page has a global CSS pause control and a script-driven component, have the component's script also respect the control, for example by checking ",[27,1539,1540],{},"matchMedia('(prefers-reduced-motion: reduce)')"," or the pause checkbox before calling ",[27,1543,68],{},[43,1545,1547],{"id":1546},"coordinating-several-animations","Coordinating several animations",[14,1549,1550,1552],{},[27,1551,187],{}," is especially useful when several elements animate together and something must happen after all of them finish. A staggered list exit, for example, applies an exit class to every item, then waits:",[215,1554,1558],{"className":1555,"code":1556,"language":1557,"meta":220,"style":220},"language-js shiki shiki-themes github-light-high-contrast github-dark-high-contrast","list.classList.add('is-leaving');\nconst running = list.getAnimations({ subtree: true });\nawait Promise.allSettled(running.map((a) => a.finished));\nlist.remove();\n","js",[27,1559,1560,1575,1599,1630],{"__ignoreMap":220},[224,1561,1562,1565,1568,1570,1573],{"class":196,"line":226},[224,1563,1564],{"class":229},"list.classList.",[224,1566,1567],{"class":919},"add",[224,1569,923],{"class":229},[224,1571,1572],{"class":258},"'is-leaving'",[224,1574,929],{"class":229},[224,1576,1577,1580,1583,1585,1588,1590,1593,1596],{"class":196,"line":244},[224,1578,1579],{"class":359},"const",[224,1581,1582],{"class":237}," running",[224,1584,913],{"class":359},[224,1586,1587],{"class":229}," list.",[224,1589,958],{"class":919},[224,1591,1592],{"class":229},"({ subtree: ",[224,1594,1595],{"class":237},"true",[224,1597,1598],{"class":229}," });\n",[224,1600,1601,1604,1607,1609,1612,1615,1618,1621,1623,1625,1627],{"class":196,"line":264},[224,1602,1603],{"class":359},"await",[224,1605,1606],{"class":237}," Promise",[224,1608,1447],{"class":229},[224,1610,1611],{"class":919},"allSettled",[224,1613,1614],{"class":229},"(running.",[224,1616,1617],{"class":919},"map",[224,1619,1620],{"class":229},"((",[224,1622,32],{"class":570},[224,1624,1019],{"class":229},[224,1626,1022],{"class":359},[224,1628,1629],{"class":229}," a.finished));\n",[224,1631,1632,1635,1638],{"class":196,"line":274},[224,1633,1634],{"class":229},"list.",[224,1636,1637],{"class":919},"remove",[224,1639,961],{"class":229},[14,1641,1490,1642,1645,1646,1649,1650,1447],{},[27,1643,1644],{},"subtree: true"," option collects animations on descendants as well as the element itself, and ",[27,1647,1648],{},"Promise.allSettled"," waits even if some animations are cancelled along the way. Because the durations and delays live in CSS, the script does not need to know how long the stagger takes; it waits exactly as long as the stylesheet says. The same pattern pauses every animation on a page for a debugging session: ",[27,1651,1652],{},"document.getAnimations().forEach((a) => a.pause())",[43,1654,1656],{"id":1655},"what-script-should-not-change","What script should not change",[14,1658,1659,1660,1663,1664,1667],{},"Once you hold the object, it is tempting to set ",[27,1661,1662],{},"anim.effect.updateTiming({ duration: 800 })"," or replace its keyframes. That works, but it silently disconnects the animation from its CSS: later changes to the stylesheet no longer apply to that animation, because script-set values override CSS-derived ones for its lifetime. It also bypasses media-query adjustments such as reduced motion. If timing needs to vary, prefer changing a custom property the CSS reads, such as ",[27,1665,1666],{},"--fill-duration",", and let the stylesheet remain the source of truth.",[43,1669,1671],{"id":1670},"variation-pausing-without-script","Variation: pausing without script",[14,1673,1674,1675,1678,1679,1681],{},"For a single pause control, script is not even necessary. A checkbox and ",[27,1676,1677],{},":has()"," can set ",[27,1680,1533],{}," on any animation in the page:",[215,1683,1687],{"className":1684,"code":1685,"language":1686,"meta":220,"style":220},"language-css shiki shiki-themes github-light-high-contrast github-dark-high-contrast","body:has(#pause-motion:checked) .loader__bar {\n  animation-play-state: paused;\n}\n","css",[27,1688,1689,1708,1720],{"__ignoreMap":220},[224,1690,1691,1693,1696,1698,1701,1703,1706],{"class":196,"line":226},[224,1692,675],{"class":233},[224,1694,1695],{"class":237},":has",[224,1697,923],{"class":229},[224,1699,1700],{"class":237},"#pause-motion:checked",[224,1702,1019],{"class":229},[224,1704,1705],{"class":237},".loader__bar",[224,1707,405],{"class":229},[224,1709,1710,1713,1715,1718],{"class":196,"line":244},[224,1711,1712],{"class":237},"  animation-play-state",[224,1714,353],{"class":229},[224,1716,1717],{"class":237},"paused",[224,1719,421],{"class":229},[224,1721,1722],{"class":196,"line":264},[224,1723,1724],{"class":229},"}\n",[1726,1727],"live-demo",{"name":1728},"has-pause-loader",[14,1730,1731,1732,1736,1737,1739],{},"This is the CSS-only approach explored in ",[32,1733,1735],{"href":1734},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fpause-controls-for-looping-animations\u002F","Pause Controls for Looping Animations",". Reach for ",[27,1738,187],{}," when you need what CSS cannot express: seeking, reversing, awaiting completion, or coordinating several animations.",[43,1741,1743],{"id":1742},"browser-support","Browser support",[14,1745,1746,1747,69,1750,1752,1753,1755,1756,1758,1759,1761,1762,1764],{},"The Web Animations API, including ",[27,1748,1749],{},"element.animate()",[27,1751,187],{}," and the ",[27,1754,91],{}," promise, is supported in Chrome 36+, Edge 79+, Firefox 48+ and Safari 13.1+ for the core API; some members, including ",[27,1757,187],{},", arrived in later versions of those browsers, so test the methods you rely on. ",[27,1760,1533],{}," is supported in Chrome 43+, Edge 12+, Firefox 16+ and Safari 9+. ",[27,1763,159],{}," is supported in Chrome 43+, Edge 12+, Firefox 16+ and Safari 9+.",[43,1766,1768],{"id":1767},"faq","FAQ",[14,1770,1771,1775,1776,1779,1780,1434,1782,1784,1785,1787,1788,1447],{},[1772,1773,1774],"strong",{},"Can JavaScript pause a CSS animation?","\nYes. Either set ",[27,1777,1778],{},"animation-play-state: paused"," through a class or style, or get the animation object with ",[27,1781,29],{},[27,1783,72],{},". The object approach also lets you seek with ",[27,1786,84],{}," and change ",[27,1789,87],{},[14,1791,1792,1795,1796,1798,1799,1801,1802,1804,1805,1807],{},[1772,1793,1794],{},"How do I know when a CSS animation has finished?","\nListen for the ",[27,1797,1463],{}," event, or await the ",[27,1800,91],{}," promise on the ",[27,1803,56],{}," object returned by ",[27,1806,187],{},". The promise is cleaner in async code; note that it rejects if the animation is cancelled, for example by removing the class.",[14,1809,1810,1813,1814,1817,1818,1820,1821,1823,1824,1826],{},[1772,1811,1812],{},"How do I restart a CSS keyframe animation?","\nRemoving and re-adding the class in the same frame does nothing, because the style never changes between frames. Call ",[27,1815,1816],{},"animation.cancel()"," then ",[27,1819,68],{}," on the object from ",[27,1822,187],{},", or set ",[27,1825,84],{}," to 0 on the running animation.",[14,1828,1829,1832,1833,1835,1836,21,1838,1840,1841,1843],{},[1772,1830,1831],{},"Are CSS animations and Web Animations API animations the same objects?","\nCSS animations and transitions appear in ",[27,1834,187],{}," as ",[27,1837,56],{},[27,1839,60],{}," objects, which extend the Web Animations API's ",[27,1842,64],{}," interface. You can control them with the same methods, while their keyframes and timing still come from CSS.",[43,1845,1847],{"id":1846},"related","Related",[1849,1850,1851,1857,1864,1871],"ul",{},[1852,1853,1854,1856],"li",{},[32,1855,35],{"href":34}," — the parent guide.",[1852,1858,1859,1863],{},[32,1860,1862],{"href":1861},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fwhen-to-use-javascript-animation\u002F","When to Use JavaScript Animation"," — the decision in general.",[1852,1865,1866,1870],{},[32,1867,1869],{"href":1868},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fanimation-fill-mode-explained\u002F","animation-fill-mode Explained"," — what forwards holds after finishing.",[1852,1872,1873,1877],{},[32,1874,1876],{"href":1875},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Finterrupted-and-reversing-transitions\u002F","Interrupted and Reversing Transitions"," — what happens mid-flight.",[336,1879,1880],{},"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 .soyes, html code.shiki .soyes{--shiki-default:#702C00;--shiki-dark:#FFB757}html pre.shiki code .sKwhi, html code.shiki .sKwhi{--shiki-default:#622CBC;--shiki-dark:#DBB7FF}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":220,"searchDepth":244,"depth":244,"links":1882},[1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894],{"id":45,"depth":244,"text":46},{"id":209,"depth":244,"text":210},{"id":1356,"depth":244,"text":1357},{"id":1375,"depth":244,"text":1376},{"id":1450,"depth":244,"text":1451},{"id":1517,"depth":244,"text":1518},{"id":1546,"depth":244,"text":1547},{"id":1655,"depth":244,"text":1656},{"id":1670,"depth":244,"text":1671},{"id":1742,"depth":244,"text":1743},{"id":1767,"depth":244,"text":1768},{"id":1846,"depth":244,"text":1847},"Keep animations in CSS and control them from script: getAnimations(), pausing and seeking, the finished promise, animation events, and clean keyframe restarts.","md",{"pageTitle":5,"datePublished":1898,"dateModified":1898,"faq":1899},"2026-09-18",[1900,1902,1904,1906],{"q":1774,"a":1901},"Yes. Either set animation-play-state: paused through a class or style, or get the animation object with element.getAnimations() and call pause(). The object approach also lets you seek with currentTime and change playbackRate.",{"q":1794,"a":1903},"Listen for the animationend event, or await the finished promise on the CSSAnimation object returned by getAnimations(). The promise is cleaner in async code; note that it rejects if the animation is cancelled, for example by removing the class.",{"q":1812,"a":1905},"Removing and re-adding the class in the same frame does nothing, because the style never changes between frames. Call animation.cancel() then play() on the object from getAnimations(), or set currentTime to 0 on the running animation.",{"q":1831,"a":1907},"CSS animations and transitions appear in getAnimations() as CSSAnimation and CSSTransition objects, which extend the Web Animations API's Animation interface. You can control them with the same methods, while their keyframes and timing still come from CSS.","\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fcontrolling-css-animations-from-javascript",{"title":5,"description":1895},"css-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fcontrolling-css-animations-from-javascript\u002Findex","kYpcsP8HTi-rm-Czi9sDF7BHOng51g1gW68gVKkHw-c",[1913,1916,1919,1922,1925,1928,1931,1934,1937,1940,1943,1946,1949,1952,1955,1958,1961,1964,1967,1970,1973,1976,1979,1982,1985,1988,1991,1992,1995,1998,2001,2004,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,2103,2106,2109,2112,2115,2118,2121,2124,2127,2130,2133,2136,2139,2142,2145,2148,2151,2154,2157,2160,2163,2166,2169,2172,2175,2178,2181,2184,2187,2190,2192,2195,2198,2201,2204,2207,2210,2213,2216,2219,2222,2225,2228,2231,2234,2237,2240,2243,2246,2249,2252,2255,2258,2261,2264,2267,2270,2273,2276,2279,2282,2285,2288,2291,2294,2297,2300,2303,2306,2309,2312,2315,2318,2321,2324,2327,2330,2333,2336,2339,2342,2345,2348,2351,2354,2357,2360,2363,2366,2369,2372,2375,2378,2381,2384,2387,2390,2393,2396,2399,2402,2405,2408,2411,2414,2417,2420,2423,2426,2429,2432,2435,2438,2441,2444,2447,2450,2453,2456,2459,2462,2465,2468],{"path":1914,"title":1915},"\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":1917,"title":1918},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fflashing-content-and-seizure-thresholds","Flashing Content and Seizure Thresholds",{"path":1920,"title":1921},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fforced-colors-mode-and-animations","Forced Colors Mode and Animations",{"path":1923,"title":1924},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations","Accessibility in CSS Animations: Patterns, Specs & Best Practices",{"path":1926,"title":1927},"\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":1929,"title":1930},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fprefers-reduced-motion-recipes","prefers-reduced-motion Recipes: A Reduction for Every Common Effect",{"path":1932,"title":1933},"\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":1935,"title":1936},"\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":1938,"title":1939},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fvestibular-safe-animation-patterns","Vestibular-Safe Animation Patterns: Why Some Motion Makes People Sick",{"path":1941,"title":1942},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fwcag-motion-success-criteria","WCAG Motion Success Criteria: What Each One Actually Requires",{"path":1944,"title":1945},"\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":1947,"title":1948},"\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":1950,"title":1951},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations","Clip-Path & Mask Animations: Animating Visibility Instead of Position",{"path":1953,"title":1954},"\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":1956,"title":1957},"\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":1959,"title":1960},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fanimating-gradients","Animating CSS Gradients: Smooth Colour Motion Without Jumps",{"path":1962,"title":1963},"\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":1965,"title":1966},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions","Color & Theme Transitions: Colour as Part of the Motion System",{"path":1968,"title":1969},"\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":1971,"title":1972},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fsmooth-theme-switching-transitions","Smooth Theme Switching: Crossfades, Circular Reveals and No Flash",{"path":1974,"title":1975},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fcontainer-query-hover-affordances","Container Query Hover Affordances: When Narrow Means Persistent, Not Hidden",{"path":1977,"title":1978},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion","Container-Aware Motion: Animation Sized by the Space a Component Actually Has",{"path":1980,"title":1981},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Flayout-change-animations-at-container-breakpoints","Animating Changes at Container Breakpoints",{"path":1983,"title":1984},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fmotion-driven-by-container-style-queries","Motion Driven by Container Style Queries",{"path":1986,"title":1987},"\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":1989,"title":1990},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fsuppressing-motion-in-small-containers","Suppressing Motion in Small Containers: Deliberately Animating Nothing",{"path":1908,"title":5},{"path":1993,"title":1994},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api","CSS Animation vs the Web Animations API: A Decision Guide",{"path":1996,"title":1997},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fwaapi-vs-css-for-interruptible-ui","Interruptible UI: CSS Transitions vs WAAPI",{"path":1999,"title":2000},"\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":2002,"title":2003},"\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":2005,"title":2006},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fcustom-property-fallbacks-and-invalid-values","Custom Property Fallbacks and Invalid Values",{"path":2008,"title":2009},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Ffluid-spacing-tokens-driving-transition-durations","Fluid Spacing Tokens That Drive Transition Durations",{"path":2011,"title":2012},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture","CSS Custom Properties Architecture: Scalable Design Systems & Dynamic UI",{"path":2014,"title":2015},"\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":2017,"title":2018},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fscoping-custom-properties-to-components","Scoping Custom Properties to Components",{"path":2020,"title":2021},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fcss-transition-timing-functions","CSS Transition Timing Functions: ease, cubic-bezier(), steps() and linear()",{"path":2023,"title":2024},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals","CSS Transition Fundamentals: Architecture, Performance & Patterns",{"path":2026,"title":2027},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Finterrupted-and-reversing-transitions","Interrupted and Reversing Transitions: What Happens Mid-Flight",{"path":2029,"title":2030},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fstarting-style-entry-animations","@starting-style: Animating an Element's Very First Style Change",{"path":2032,"title":2033},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransition-delay-choreography","Choreographing Motion With transition-delay",{"path":2035,"title":2036},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransition-shorthand-and-multiple-properties","The transition Shorthand and Multiple Properties",{"path":2038,"title":2039},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransitioning-display-with-allow-discrete","Transitioning display with transition-behavior: allow-discrete and @starting-style",{"path":2041,"title":2042},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fanimating-dialog-open-and-close","Animating \u003Cdialog> Open and Close: Both Directions, No Library",{"path":2044,"title":2045},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fbackdrop-animations","Animating ::backdrop: Fades and Blurs Behind Dialogs and Popovers",{"path":2047,"title":2048},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations","Dialog & Popover Animations: Motion for the Top Layer",{"path":2050,"title":2051},"\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":2053,"title":2054},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fpopover-entry-and-exit-transitions","Popover Menus That Animate From Their Anchor",{"path":2056,"title":2057},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fchoosing-animation-durations","Choosing Animation Durations: How Long Motion Should Last",{"path":2059,"title":2060},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fcubic-bezier-overshoot-and-anticipation","Overshoot and Anticipation With cubic-bezier(): Motion With Character",{"path":2062,"title":2063},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fentry-vs-exit-easing","Entry vs Exit Easing: Different Curves for Arriving and Leaving",{"path":2065,"title":2066},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design","Easing & Motion Design: Making CSS Motion Feel Intentional",{"path":2068,"title":2069},"\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":2071,"title":2072},"\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":2074,"title":2075},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Faccessible-css-only-tooltips","Accessible CSS-Only Tooltips and Hover Cards With  and ",{"path":2077,"title":2078},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fbutton-press-and-active-states","Button Press and  States",{"path":2080,"title":2081},"\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":2083,"title":2084},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Ffocus-within-form-patterns"," Form Patterns: Styling a Group From the Field Inside It",{"path":2086,"title":2087},"\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":2089,"title":2090},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design","Hover & Focus State Design: Spec-Compliant Patterns for Modern UIs",{"path":2092,"title":2093},"\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":2095,"title":2096},"\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":2098,"title":2099},"\u002Fcss-only-micro-interactions-animations","CSS-Only Micro-Interactions & Animations: Architecture, Performance & Implementation",{"path":2101,"title":2102},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fanimation-composition-and-stacking","Stacking Animations With animation-composition",{"path":2104,"title":2105},"\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":2107,"title":2108},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcontainer-query-triggered-keyframe-animations","Container-Query-Triggered Keyframe Animations: Animate Differently per Available Space",{"path":2110,"title":2111},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcss-only-accordions-and-disclosure","CSS-Only Accordions and Disclosure Widgets with details and summary",{"path":2113,"title":2114},"\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":2116,"title":2117},"\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":2119,"title":2120},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns","Keyframe Animation Patterns: Spec-Compliant Architectures for Modern UIs",{"path":2122,"title":2123},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fmulti-step-keyframes-and-per-keyframe-easing","Multi-Step Keyframes and Per-Keyframe Easing",{"path":2125,"title":2126},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fstaggered-list-animations-with-custom-properties","Staggered List Animations Using --i Index Custom Properties",{"path":2128,"title":2129},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fanimating-box-shadow-and-filters-cheaply","Animating box-shadow and Filters Cheaply",{"path":2131,"title":2132},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fcontain-property-for-animation-performance","The contain Property for Animation Performance",{"path":2134,"title":2135},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fcss-triggers-layout-paint-composite","Layout, Paint and Composite: What Triggers What",{"path":2137,"title":2138},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration","Performance & GPU Acceleration in CSS: A Developer’s Blueprint",{"path":2140,"title":2141},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Foptimizing-css-animations-for-60fps","Optimizing CSS Animations for 60fps: Budgeting the Frame",{"path":2143,"title":2144},"\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":2146,"title":2147},"\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":2149,"title":2150},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations","Scroll-Driven Animations: Binding Motion to Scroll Position in Pure CSS",{"path":2152,"title":2153},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-driven-animation-fallbacks","Shipping Scroll-Driven Animations Without Breaking Anything",{"path":2155,"title":2156},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-driven-parallax-effects","Scroll-Driven Parallax Effects in CSS",{"path":2158,"title":2159},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-progress-bar-without-javascript","A Reading Progress Bar Driven by scroll(root)",{"path":2161,"title":2162},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-triggered-reveal-animations","Reveal-on-Scroll with view() and animation-range",{"path":2164,"title":2165},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Ftimeline-scope-for-cross-element-animations","timeline-scope for Cross-Element Animations",{"path":2167,"title":2168},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fview-timeline-and-animation-range","View Timelines and animation-range",{"path":2170,"title":2171},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fcross-document-view-transitions","Cross-Document View Transitions",{"path":2173,"title":2174},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers","View Transitions for CSS Developers: the Pseudo-Element Tree, Snapshots, and Named Elements",{"path":2176,"title":2177},"\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":2179,"title":2180},"\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":2182,"title":2183},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transition-types-and-classes","View Transition Types and Classes",{"path":2185,"title":2186},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transitions-for-list-reordering","View Transitions for List Reordering",{"path":2188,"title":2189},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transitions-with-reduced-motion","Honouring prefers-reduced-motion in View Transitions",{"path":363,"title":2191},"Modern CSS Layouts & Micro-Interactions",{"path":2193,"title":2194},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-positioned-tooltips","Anchor-Positioned Tooltips: Tethering, Flipping, and Getting the Semantics Right",{"path":2196,"title":2197},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-positioning-fallbacks","Anchor Positioning Fallbacks: A Graceful Floor for Older Browser Versions",{"path":2199,"title":2200},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-size-for-matching-widths","anchor-size(): Overlays That Match Their Trigger's Size",{"path":2202,"title":2203},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays","CSS Anchor Positioning and Overlays: Tethering Elements Without JavaScript",{"path":2205,"title":2206},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fpopover-attribute-and-css-styling","The popover Attribute: Top-Layer Overlays With No JavaScript",{"path":2208,"title":2209},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fpopover-light-dismiss-and-stacking","Popover Light Dismiss, Nesting and Stacking",{"path":2211,"title":2212},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fposition-area-grid-explained","position-area: The Anchor Placement Grid",{"path":2214,"title":2215},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fcontainer-query-polyfill-tradeoffs","Container Query Polyfills: What They Cost and When to Skip Them",{"path":2217,"title":2218},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Ffeature-detection-with-supports","Feature Detection with @supports: Syntax, Semantics, and the Traps",{"path":2220,"title":2221},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fhandling-container-query-fallbacks-for-older-browsers","Handling Container Query Fallbacks for Older Browsers",{"path":2223,"title":2224},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks","Container Query Fallbacks: Spec-Compliant CSS Strategies for Legacy Browsers",{"path":2226,"title":2227},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fintrinsic-layout-fallbacks-without-queries","Intrinsic Layout Fallbacks: Baselines That Adapt Without Any Query",{"path":2229,"title":2230},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Ftesting-fallbacks-without-old-browsers","Testing CSS Fallbacks Without an Old Browser",{"path":2232,"title":2233},"\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":2235,"title":2236},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-query-range-and-logic-operators","Container Query Range Syntax and Logic Operators",{"path":2238,"title":2239},"\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":2241,"title":2242},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-type-size-vs-inline-size","Choosing container-type: inline-size, size, or normal",{"path":2244,"title":2245},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-vs-media-queries-comparison","Container vs Media Queries: Choosing the Right Reference Box",{"path":2247,"title":2248},"\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":2250,"title":2251},"\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":2253,"title":2254},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics","Container Query Syntax Basics",{"path":2256,"title":2257},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fnesting-and-naming-container-queries","Nesting and Naming Container Queries: Targeting the Right Ancestor",{"path":2259,"title":2260},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fauto-fit-minmax-responsive-grids","Responsive Grids with repeat(auto-fit, minmax())",{"path":2262,"title":2263},"\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":2265,"title":2266},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fgrid-auto-flow-dense-packing","grid-auto-flow: dense for Packed Layouts",{"path":2268,"title":2269},"\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":2271,"title":2272},"\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":2274,"title":2275},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts","CSS Grid and Subgrid Layouts for Responsive Interfaces",{"path":2277,"title":2278},"\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":2280,"title":2281},"\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":2283,"title":2284},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fsubgrid-vs-nested-grid","Subgrid vs an Independently Nested Grid",{"path":2286,"title":2287},"\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":2289,"title":2290},"\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":2292,"title":2293},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-grow-and-flex-shrink-explained","flex-grow and flex-shrink Explained",{"path":2295,"title":2296},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-wrap-intrinsic-responsive-rows","Breakpoint-Free Responsive Rows With flex-wrap and flex-basis",{"path":2298,"title":2299},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflexbox-gap-and-spacing","Flexbox gap vs Margins: Spacing Items Without Edge Hacks",{"path":2301,"title":2302},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns","Flexbox Layout Patterns: One-Dimensional Layout for Real Components",{"path":2304,"title":2305},"\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":2307,"title":2308},"\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":2310,"title":2311},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Fdebugging-clamp-values","Debugging clamp(): Values That Are Ignored, Stuck or Never Fluid",{"path":2313,"title":2314},"\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":2316,"title":2317},"\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":2319,"title":2320},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-type-accessibility-and-zoom","Fluid Type, Accessibility and Zoom: The vw-Only Trap",{"path":2322,"title":2323},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-typography-without-javascript","Fluid Typography Without JavaScript: A Precision CSS Reference",{"path":2325,"title":2326},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp","Fluid Typography with clamp(): A Practical Guide for Modern CSS",{"path":2328,"title":2329},"\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":2331,"title":2332},"\u002Fmastering-container-queries-responsive-layouts","Mastering Container Queries & Responsive Layouts",{"path":2334,"title":2335},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Faspect-ratio-for-responsive-media","Using aspect-ratio for Responsive Media and Preventing Layout Shift",{"path":2337,"title":2338},"\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":2340,"title":2341},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques","Intrinsic Sizing Techniques: Modern CSS Layouts for Responsive UI",{"path":2343,"title":2344},"\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":2346,"title":2347},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fmin-max-fit-content-explained","min-content, max-content, and fit-content() Explained",{"path":2349,"title":2350},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fobject-fit-and-object-position","object-fit and object-position: Images That Fit Any Box",{"path":2352,"title":2353},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fpreventing-flex-and-grid-overflow","The min-width: auto Trap in Flex and Grid Layouts",{"path":2355,"title":2356},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcascade-layers-for-reset-and-tokens","Cascade Layers for Reset and Design Tokens",{"path":2358,"title":2359},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcascade-layers-vs-specificity-hacks","Cascade Layers vs Specificity Hacks: Ordering Instead of Escalating",{"path":2361,"title":2362},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcss-scope-for-component-styles","@scope for Component Styles: Short Selectors That Cannot Leak",{"path":2364,"title":2365},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies","Modern CSS Reset Strategies: A Spec-Compliant Foundation",{"path":2367,"title":2368},"\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":2370,"title":2371},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fwriting-a-minimal-modern-reset","Writing a Minimal Modern CSS Reset: Every Line Justified",{"path":2373,"title":2374},"\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":2376,"title":2377},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fempty-and-loading-states-with-has","Empty and Loading States With ()",{"path":2379,"title":2380},"\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":2382,"title":2383},"\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":2385,"title":2386},"\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":2388,"title":2389},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has","Parent-Aware Layouts With :has(): Letting Containers React to Their Contents",{"path":2391,"title":2392},"\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":2394,"title":2395},"\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":2397,"title":2398},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fcontainer-query-data-tables","Container Query Data Tables: Reflowing Tables to Cards",{"path":2400,"title":2401},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fcontainer-query-sidebar-layouts","Container Query Sidebar Layouts That Travel Between Contexts",{"path":2403,"title":2404},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns","Responsive Component Patterns: Architecture & Implementation",{"path":2406,"title":2407},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-forms-with-container-queries","Responsive Forms with Container Queries: Reflow Without Losing the Wiring",{"path":2409,"title":2410},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-hero-sections-with-container-queries","Responsive Hero Sections With Container Queries",{"path":2412,"title":2413},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-navigation-without-media-queries","Responsive Navigation Without Media Queries Using Container Queries",{"path":2415,"title":2416},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-pricing-tables","Responsive Pricing Tables: Aligned Features, a Clear Recommendation, Any Width",{"path":2418,"title":2419},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Ftabs-that-become-accordions","Tabs That Become an Accordion: One Component, Two Layouts",{"path":2421,"title":2422},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Fcss-only-carousel-with-scroll-snap","A CSS-Only Carousel With Scroll Snap",{"path":2424,"title":2425},"\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":2427,"title":2428},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts","Scroll Snap & Overflow Layouts: Designing Components That Scroll on Purpose",{"path":2430,"title":2431},"\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":2433,"title":2434},"\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":2436,"title":2437},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fcombining-size-and-style-queries","Combining Size and Style Container Queries",{"path":2439,"title":2440},"\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":2442,"title":2443},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state","Style Queries and Container State: Token-Driven Component Variants",{"path":2445,"title":2446},"\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":2448,"title":2449},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fstyle-query-component-variants","Component Variants With Style Queries: One Token, Many Looks",{"path":2451,"title":2452},"\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":2454,"title":2455},"\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":2457,"title":2458},"\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":2460,"title":2461},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout","Viewport Units & Mobile Layout: Designing for the Screen You Actually Get",{"path":2463,"title":2464},"\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":2466,"title":2467},"\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":2469,"title":2470},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fvirtual-keyboard-and-interactive-widget","Layouts That Survive the Virtual Keyboard",{"title":2472,"caption":2473,"height":2474,"html":2475,"css":2476},"Pausing a CSS animation without script","Tick the checkbox to pause the looping bar; untick to resume from the same point. animation-play-state is set through :has() on the page.",170,"\n\u003Cdiv class=\"wrap\">\n  \u003Clabel class=\"toggle\">\u003Cinput type=\"checkbox\" id=\"pause-motion\"> Pause animation\u003C\u002Flabel>\n  \u003Cdiv class=\"loader\">\u003Cdiv class=\"loader__bar\">\u003C\u002Fdiv>\u003C\u002Fdiv>\n\u003C\u002Fdiv>","\n.wrap { display: grid; gap: 1rem; padding: 1.5rem; max-inline-size: 22rem; }\n.toggle { display: flex; gap: 0.5rem; align-items: center; }\n.loader { block-size: 0.5rem; border-radius: 999px; background: var(--demo-border); overflow: hidden; }\n.loader__bar { block-size: 100%; background: var(--demo-accent); transform-origin: left; animation: fill 4s linear infinite; }\n@keyframes fill { from { scale: 0 1; } to { scale: 1 1; } }\nbody:has(#pause-motion:checked) .loader__bar { animation-play-state: paused; }\n@media (prefers-reduced-motion: reduce) { .loader__bar { animation-duration: 12s; } }",1789717747706]