mirror of
https://github.com/tomfran/typo.git
synced 2025-04-25 21:19:55 +03:00
Merge pull request #102 from runofthemillgeek/fix/aspect-ratio-layout-shift
Fix layout shifts by preserving aspect-ratio at responsive sizes
This commit is contained in:
commit
01624638b9
2 changed files with 13 additions and 12 deletions
|
@ -440,18 +440,19 @@ footer a {
|
|||
|
||||
/* images */
|
||||
|
||||
figure>div {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
figure {
|
||||
.img-container {
|
||||
aspect-ratio: var(--w) / var(--h);
|
||||
max-height: var(--figure-img-max-height);
|
||||
width: auto;
|
||||
margin-inline: auto;
|
||||
}
|
||||
|
||||
figure img {
|
||||
max-width: 100%;
|
||||
max-height: var(--figure-img-max-height);
|
||||
width: auto;
|
||||
height: auto;
|
||||
margin-inline: auto;
|
||||
img {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.dark .img-light {
|
||||
|
|
|
@ -46,7 +46,7 @@ and build the img class string as "img-tag1 img-tag2 ..."
|
|||
{{/* Use the computed classes on the rendered figure */}}
|
||||
<figure class="{{ $classes }}">
|
||||
|
||||
<div>
|
||||
<div class="img-container" {{ with $imgResource }}style="--w: {{ .Width }}; --h: {{ .Height }};"{{ end }}>
|
||||
<img loading="lazy" alt="{{ .Text }}" src="{{ $url }}" {{ with $imgResource }}width="{{ .Width }}" height="{{ .Height }}"{{ end }}>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue