Beispiel:Bilder präsentieren-3.html

Aus SELFHTML-Wiki
Wechseln zu: Navigation, Suche
<!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;
  text-align: center; 
}

#gallery figure {
  position: relative;
  color: black;
  background: white;
}

figure img {
  width: 100%;
  display: block;
}

#gallery > figure > figcaption {
  position: absolute;
  bottom: 0;
  width: 100%;
  line-height: 3em;
  color: white;
  background: rgb(0 0 0 0.3);
}

#gallery > figcaption {
  grid-column: 1 / -1;
}

</style>
</head>

<body>
  <h1>Bildunterschriften mit figcaption präsentieren</h1>
  <main>
    <figure id="gallery">
      <figcaption>Ansichten von Lauf an der Pegnitz</figcaption>

      <figure>
        <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>
        <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>
        <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>