possible to close overlay by clicking on it

This commit is contained in:
hugogogo
2026-11-19 18:22:25 +01:00
parent 779033e4ca
commit 58981fe7e8
+63
View File
@@ -66,6 +66,24 @@
display: block;
}
/* invisible full-screen link behind the images : clicking the dark
backdrop closes the overlay (targets the section => no :target
inside the overlay anymore) */
.lightbox_bg {
position: fixed;
inset: 0;
z-index: 1;
span {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect(0 0 0 0);
white-space: nowrap;
}
}
/* white rounded square with a gray cross (pure css, the fr/en
labels stay in the html, visually hidden but read by screen readers) */
.lightbox_close {
@@ -108,11 +126,20 @@
/* the overlay gallery : one single full-width column of images */
.lightbox_list {
position: relative;
z-index: 2;
display: grid;
grid-template-columns: 1fr;
gap: 30px;
width: min(1100px, calc(100vw - 20px));
margin: 60px auto;
/* scrolling must work over the whole list, so pointer-events stay
on ; instead each image is wrapped in a link to the section, so
clicking an image closes the overlay (and the border/gutters
still close via the backdrop link) */
a {
display: block;
}
img {
width: 100%;
@@ -307,91 +334,127 @@
the right image. The close link targets the section, which hides
the overlay again -->
<div class="lightbox">
<a class="lightbox_bg" href="#portfolio_section">
<span class="fr">fermer</span>
<span class="en" lang="en">close</span>
</a>
<a class="lightbox_close" href="#portfolio_section">
<span class="fr">fermer</span>
<span class="en" lang="en">close</span>
</a>
<div class="lightbox_list">
<a href="#portfolio_section">
<img
id="p1"
src="./src/docs/images/crafts/banane_1-banane_kisskissbankbank_1_1_square.jpg"
alt="banane 1"
/>
</a>
<a href="#portfolio_section">
<img
id="p2"
src="./src/docs/images/crafts/banane_2-IMG_banane_1_4_square.jpg"
alt="banane 2"
/>
</a>
<a href="#portfolio_section">
<img
id="p3"
src="./src/docs/images/crafts/banane_3-IMG_banane_4_7_square.jpg"
alt="banane 3"
/>
</a>
<a href="#portfolio_section">
<img
id="p4"
src="./src/docs/images/crafts/banane_4-2-IMG_banane_3_15.jpg"
alt="banane 4"
/>
</a>
<a href="#portfolio_section">
<img
id="p5"
src="./src/docs/images/crafts/manteau_1-manteau24_planche_1_3_square.jpg"
alt="manteau 1"
/>
</a>
<a href="#portfolio_section">
<img
id="p6"
src="./src/docs/images/crafts/manteau_2-IMG_manteau_4_8_square.jpg"
alt="manteau 2"
/>
</a>
<a href="#portfolio_section">
<img
id="p7"
src="./src/docs/images/crafts/manteau_3-planche_3_1.jpg"
alt="manteau 3"
/>
</a>
<a href="#portfolio_section">
<img
id="p8"
src="./src/docs/images/crafts/manteau_4-IMG_manteau_2_8_square.jpg"
alt="manteau 4"
/>
</a>
<a href="#portfolio_section">
<img
id="p9"
src="./src/docs/images/crafts/sacoche_1-planche_5_2_square.jpg"
alt="sacoche 1"
/>
</a>
<a href="#portfolio_section">
<img
id="p10"
src="./src/docs/images/crafts/sacoche_2-planche_3_2_square.jpg"
alt="sacoche 2"
/>
</a>
<a href="#portfolio_section">
<img
id="p11"
src="./src/docs/images/crafts/sacoche_3-photos3_sacoche_2_square.jpg"
alt="sacoche 3"
/>
</a>
<a href="#portfolio_section">
<img
id="p12"
src="./src/docs/images/crafts/sacoche_4-planche_4_2_square.jpg"
alt="sacoche 4"
/>
</a>
<a href="#portfolio_section">
<img
id="p13"
src="./src/docs/images/crafts/velo_1-IMG_velo_1_11_square.jpg"
alt="velo 1"
/>
</a>
<a href="#portfolio_section">
<img
id="p14"
src="./src/docs/images/crafts/velo_2-IMG_velo_3_12_square.jpg"
alt="velo 2"
/>
</a>
<a href="#portfolio_section">
<img
id="p15"
src="./src/docs/images/crafts/velo_3-velo_1_6_square.jpg"
alt="velo 3"
/>
</a>
<a href="#portfolio_section">
<img
id="p16"
src="./src/docs/images/crafts/velo_4-velo_2_9_square.jpg"
alt="velo 4"
/>
</a>
</div>
</div>