CSSイメージギャラリーログイン

CSSイメージギャラリー

CSSを使用して画像ギャラリーを作成します:

を以下に示します

1002.jpg1003.jpg1004.jpg1005.jpg

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php.cn</title>
<style type="text/css">
div.img
{
  margin: 2px;
  border: 1px solid #0000ff;
  height: auto;
  width: auto;
  float: left;
  text-align: center;
}
div.img img
{
  display: inline;
  margin: 3px;
  border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
div.desc
{
  text-align: center;
  font-weight: normal;
  width: 120px;
  margin: 2px;
}
</style>
</head>
<body>
<div class="img">
 <a href="#"><img src="http://img.php.cn/upload/image/837/831/318/1476339949246926.jpg" 
alt="Klematis" width="110" height="90"></a>
 <div class="desc">1</div>
</div>
<div class="img">
<a href="#"><img src="http://img.php.cn/upload/image/153/383/263/1476339955769441.jpg" 
alt="Klematis" width="110" height="90"></a>
 <div class="desc">2</div>
</div>
<div class="img">
 <a href="#"><img src="http://img.php.cn/upload/image/815/625/584/1476339961304990.jpg" 
alt="Klematis" width="110" height="90"></a>
 <div class="desc">3</div>
</div>
<div class="img">
 <a href="#"><img src="http://img.php.cn/upload/image/870/504/597/1476339972616793.jpg" 
alt="Klematis" width="110" height="90"></a>
 <div class="desc">4</div>
</div>
</body>
</html>

コードの説明:

CSS イメージ ギャラリー表示される各画像に対して 2 つの div レイヤーを使用します。 タグ内の タグは、画像のパスを設定します。ヒント; 内側の div には画像の説明が表示され、その CSS クラスは

div.img で、「img」クラスの属性を定義します。 2px;
ボーダー: 1px、実線、色;
幅: 自動;
テキストを中央に配置;
inline要素;独自の独立したスペースであり、他のブロックにアタッチされます。 Level 要素が存在するため、インライン要素の高さ、幅、内側と外側のマージンなどの属性の設定は無効です。
Margin: 3px;
Border: 1px、実線、色;



div.desc

テキスト配置: 中央配置フォントウェイト: 標準幅: 120px
マージン: 2px


div.img a:hover img {border: 1px Solid #0000ff;}

マウスオーバーでimg 枠線と色が変わります

次のセクション

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php.cn</title> <style type="text/css"> div.img { margin: 2px; border: 1px solid #0000ff; height: auto; width: auto; float: left; text-align: center; } div.img img { display: inline; margin: 3px; border: 1px solid #ffffff; } div.img a:hover img {border: 1px solid #0000ff;} div.desc { text-align: center; font-weight: normal; width: 120px; margin: 2px; } </style> </head> <body> <div class="img"> <a href="#"><img src="https://img.php.cn//upload/image/837/831/318/1476339949246926.jpg" alt="Klematis" width="110" height="90"></a> <div class="desc">1</div> </div> <div class="img"> <a href="#"><img src="https://img.php.cn//upload/image/153/383/263/1476339955769441.jpg" alt="Klematis" width="110" height="90"></a> <div class="desc">2</div> </div> <div class="img"> <a href="#"><img src="https://img.php.cn//upload/image/815/625/584/1476339961304990.jpg" alt="Klematis" width="110" height="90"></a> <div class="desc">3</div> </div> <div class="img"> <a href="#"><img src="https://img.php.cn//upload/image/870/504/597/1476339972616793.jpg" alt="Klematis" width="110" height="90"></a> <div class="desc">4</div> </div> </body> </html>
コースウェア