CSS イメージギャラリ

❮ 前章へ 次章へ ❯

CSS は、イメージギャラリの作成に使用することができます。

Trolltunga Norway
Add a description of the image here
Forest
Add a description of the image here
Northern Lights
Add a description of the image here
Mountains
Add a description of the image here

イメージギャラリ

次のイメージギャラリは、CSS で作成しています:

<html>
<head>
<style>
div.img {
    margin: 5px;
    border: 1px solid #ccc;
    float: left;
    width: 180px;
}

div.img:hover {
    border: 1px solid #777;
}

div.img img {
    width: 100%;
    height: auto;
}

div.desc {
    padding: 15px;
    text-align: center;
}
</style>
</head>
<body>

<div class="img">
  <a target="_blank" href="fjords.jpg">
    <img src="fjords.jpg" alt="Fjords" width="300" height="200">
  </a>
  <div class="desc">Add a description of the image here</div>
</div>

<div class="img">
  <a target="_blank" href="forest.jpg">
    <img src="forest.jpg" alt="Forest" width="300" height="200">
  </a>
  <div class="desc">Add a description of the image here</div>
</div>

<div class="img">
  <a target="_blank" href="lights.jpg">
    <img src="lights.jpg" alt="Northern Lights" width="300" height="200">
  </a>
  <div class="desc">Add a description of the image here</div>
</div>

<div class="img">
  <a target="_blank" href="mountains.jpg">
    <img src="mountains.jpg" alt="Mountains" width="300" height="200">
  </a>
  <div class="desc">Add a description of the image here</div>
</div>

</body>
</html>
Try it Yourself ❯

Examples

その他の例

レスポンシブ・イメージギャラリ
レスポンシブ・イメージギャラリを作成するための CSS3 メディア・クエリに使用方法。

高度:クリック可能なモーダル・イメージ (JS)
モーダルボックスにクリックした画像を表示するために、CSS と一緒に JavaScript を使用する方法の例です。


❮ 前章へ 次章へ ❯