import{_ as s,c as i,a2 as t,o as e}from"./chunks/framework.DPuwY6B9.js";const c=JSON.parse('{"title":"Aspect Ratio for Blurry Placeholders","description":"","frontmatter":{},"headers":[],"relativePath":"advanced/aspect-ratio.md","filePath":"advanced/aspect-ratio.md"}'),l={name:"advanced/aspect-ratio.md"};function n(h,a,p,o,r,d){return e(),i("div",null,a[0]||(a[0]=[t(`<h1 id="aspect-ratio-for-blurry-placeholders" tabindex="-1">Aspect Ratio for Blurry Placeholders <a class="header-anchor" href="#aspect-ratio-for-blurry-placeholders" aria-label="Permalink to &quot;Aspect Ratio for Blurry Placeholders&quot;">​</a></h1><p>In certain cases, the blurry placeholder might not have the full image width and height. To ensure that the layout does not change when the full-quality image loads and to maintain a consistent user experience, you can add the <code>aspect-ratio</code> CSS property to the <code>style</code> attribute to your images.</p><p>By setting the aspect ratio for your blurry placeholders, you can:</p><ul><li>Prevent layout shifts as the full-quality image loads.</li><li>Ensure that the image container maintains its dimensions even before the full-quality image is loaded.</li></ul><h2 id="usage" tabindex="-1">Usage <a class="header-anchor" href="#usage" aria-label="Permalink to &quot;Usage&quot;">​</a></h2><p>Calculate the aspect ratio using the dimensions of the full-quality image (width / height) and apply it to the <code>&lt;img&gt;</code> tag:</p><div class="language-html vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&lt;</span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">img</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">  src</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;data:image/svg+xml, ...&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">  loading</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;lazy&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">  data-srcset</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;/foo.png 1024w, /foo-2x.png 2048w&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">  data-sizes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;auto&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">  width</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;1600&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">  height</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;900&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">  style</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;aspect-ratio: 16/9;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt;</span></span></code></pre></div>`,7)]))}const u=s(l,[["render",n]]);export{c as __pageData,u as default};
