Beispiel:Bilder präsentieren-4.html
Aus SELFHTML-Wiki
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" media="screen" href="./Beispiel:SELFHTML-Beispiel-Grundlayout.css" />
<title>Bildunterschriften mit figcaption präsentieren</title>
<style>
figure, figcaption {
margin: 0;
padding: 0;
}
#gallery {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(15em, 1fr));
gap: 1em;
}
#gallery figure {
position: relative;
overflow:hidden;
}
#gallery figure:before {
content: "?";
position: absolute;
bottom: 1em;
left: 1em;
background: white;
color: black;
opacity: 0.7;
width: 1.5em;
height: 1.5em;
border-radius: 1em;
text-align: center;
font-size: 1.5em;
line-height: 1.5em;
transition: all 1s ease;
}
#gallery figure:focus:before,
#gallery figure:hover:before {
opacity: 0;
}
figure img {
width: 100%;
display: block;
}
#gallery > figure > figcaption {
position: absolute;
width: 100%;
text-align: center;
line-height: 3em;
color: white;
background: rgba(0,0,0,0.3);
opacity: 0;
bottom: -3em;
transition: all 1s ease;
}
figure.mitte figcaption {
width: 0;
left: 50%;
}
#gallery > figure.rechts > figcaption {
width: 0;
bottom: 50%;
left: 50%;
}
#gallery > figure:hover > figcaption,
#gallery > figure:focus > figcaption {
opacity: 1;
bottom: 0;
left: 0;
width: 100%;
}
#gallery > figcaption {
grid-column: 1 / -1;
text-align: center;
}
</style>
</head>
<body>
<h1>Bildunterschriften mit figcaption präsentieren</h1>
<main>
<figure id="gallery">
<figcaption>Ansichten von Lauf an der Pegnitz</figcaption>
<figure tabindex=0>
<img src="//wiki.selfhtml.org/images/a/a6/Lauf-1.jpg" alt="Lauf an der Pegnitz - Nürnberger Tor">
<figcaption>Nürnberger Tor</figcaption>
</figure>
<figure tabindex=0 class="mitte">
<img src="//wiki.selfhtml.org/images/4/4a/Lauf-2.jpg" alt="Lauf an der Pegnitz - Pegnitz">
<figcaption>Brücke über die Pegnitz</figcaption>
</figure>
<figure tabindex=0 class="rechts">
<img src="//wiki.selfhtml.org/images/2/24/Lauf-3.jpg" alt="Lauf an der Pegnitz - Nürnberger Tor">
<figcaption>Mauermühle und Judenturm</figcaption>
</figure></figure>
</main>
</body>
</html>