Skip to content

Commit 1ac25ed

Browse files
committed
Stop text jumping around after images load
1 parent f66cb4f commit 1ac25ed

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

html/place.html

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22

33
{% block extra_head %}
44
<style>
5-
.food-image {
5+
.food-image-container {
66
margin-top: 1rem;
7-
width: auto;
8-
max-width: 100%;
9-
height: auto;
7+
width: 100%;
8+
height: 0;
9+
padding-bottom: 56.25%; /* 16:9 aspect ratio (9/16 = 0.5625) */
10+
position: relative;
11+
background-color: #ffffff;
12+
}
13+
.food-image {
14+
position: absolute;
15+
top: 0;
16+
left: 0;
17+
width: 100%;
18+
height: 100%;
19+
object-fit: cover;
1020
}
1121
.sampling-date {
1222
font-style: italic;
@@ -141,15 +151,17 @@ <h1 class="name">{{ name }}</h1>
141151
<p><b class="sgfi">Something Going For It</b></p>
142152
{% endif %}
143153
{% if food_image_path %}
144-
<picture>
145-
{% if food_image_path.endswith('.webp') %}
146-
<source srcset="{{ food_image_path }}" type="image/webp">
147-
<source srcset="{{ food_image_path.replace('.webp', '.jpg') }}" type="image/jpeg">
148-
<img src="{{ food_image_path.replace('.webp', '.jpg') }}" alt="{{ alt_text }}" class="food-image" loading="lazy" width="800" height="450">
149-
{% else %}
150-
<img src="{{ food_image_path }}" alt="{{ alt_text }}" class="food-image" loading="lazy" width="800" height="450">
151-
{% endif %}
152-
</picture>
154+
<div class="food-image-container">
155+
<picture>
156+
{% if food_image_path.endswith('.webp') %}
157+
<source srcset="{{ food_image_path }}" type="image/webp">
158+
<source srcset="{{ food_image_path.replace('.webp', '.jpg') }}" type="image/jpeg">
159+
<img src="{{ food_image_path.replace('.webp', '.jpg') }}" alt="{{ alt_text }}" class="food-image" loading="lazy" width="1200" height="675">
160+
{% else %}
161+
<img src="{{ food_image_path }}" alt="{{ alt_text }}" class="food-image" loading="lazy" width="1200" height="675">
162+
{% endif %}
163+
</picture>
164+
</div>
153165
{% endif %}
154166
<h3 class="notes">Remarks</h3>
155167
{{ content }}

0 commit comments

Comments
 (0)