Skip to content

Commit 5e2dd7b

Browse files
committed
ui: rework the double-img helper to make it usable
modeled off of the excellent work by jonas on https://www.jonashietala.se/
1 parent 28455a5 commit 5e2dd7b

2 files changed

Lines changed: 27 additions & 23 deletions

File tree

_includes/double-img.html

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
<div>
2-
<a href="{{ include.src1 }}">
3-
<img
4-
src="{{ include.src1 }}"
5-
class="inline-img"
6-
/>
7-
</a>
1+
<div style="display:grid">
2+
<figure class="inline-img-container">
3+
<a class="inline-img-link" href="{{ include.src1 }}">
4+
<img src="{{ include.src1 }}" />
5+
</a>
86

9-
<a href="{{ include.src2 }}">
10-
<img
11-
src="{{ include.src2 }}"
12-
class="inline-img"
13-
/>
14-
</a>
7+
<a class="inline-img-link" href="{{ include.src2 }}">
8+
<img src="{{ include.src2 }}" />
9+
</a>
10+
<figcaption>{{ include.caption }}</figcaption>
11+
</figure>
1512
</div>

_sass/base.scss

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ figure {
9797
}
9898

9999
figcaption {
100+
width: 100%;
100101
font-size: 0.9rem;
101102
color: var(--text-light);
102103
text-align: center;
103104
margin-bottom: 1rem;
105+
font-style: italic;
104106
}
105107

106108
pre {
@@ -128,17 +130,22 @@ hr {
128130
}
129131

130132
.inline-img-container {
131-
@media (min-width: 768px) {
132-
display: flex;
133-
}
133+
width: 100%;
134+
grid-column: 2/5 !important;
135+
max-inline-size: none;
136+
display: flex;
137+
flex-wrap: wrap;
138+
text-align: center;
139+
justify-content: center;
140+
align-items: center;
141+
}
142+
143+
.inline-img-link {
144+
flex: 0 1 45%;
145+
padding-inline: 1%;
134146
}
135147

136148
.inline-img {
137-
@media (min-width: 768px) {
138-
flex: auto;
139-
max-width: 45%;
140-
}
141-
@media (max-width: 768px) {
142-
max-width: 25rem;
143-
}
149+
max-width: 100%;
150+
max-inline-size: 100%;
144151
}

0 commit comments

Comments
 (0)