CSS实例:图片导航块

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>img</title>
    <link rel="stylesheet" type="text/css" href="../static/css/171020.css">



</head>
<body>
<div class="recommand">
    <div class="img">
        <a href=" http://wenda.so.com/q/1369022692065247?src=140"><img src="http://p0.so.qhimgs1.com/bdr/_240_/t01b5b18fe8165f0090.jpg"></a>
        <div class="desc"><a href=" http://wenda.so.com/q/1369022692065247?src=140">panda</a></div>
    </div>
    <div class="img">
        <a href=" http://wenda.so.com/q/1369022692065247?src=140"><img src="http://img8.house365.com/szbbsuserpic/2014/01/24/139054836752e2158feac66.jpg"></a>
        <div class="desc"><a href=" http://wenda.so.com/q/1369022692065247?src=140">熊猫</a></div>
    </div>
    <div class="img">
        <a href=" http://wenda.so.com/q/1369022692065247?src=140"><img src="http://p0.so.qhimgs1.com/bdr/_240_/t01b5b18fe8165f0090.jpg"></a>
        <div class="desc"><a href=" http://wenda.so.com/q/1369022692065247?src=140">啦啦</a></div>
    </div>
</div>
<div>
     <div>
         <a href="https://www.so.com/s?q=关爱大熊猫&src=tab_image"><img src="http://p4.so.qhimgs1.com/t015a07eebcdb1726e4.jpg"></a><br>
        <img src="http://p0.so.qhimgs1.com/bdr/_240_/t01b5b18fe8165f0090.jpg"><br>
        <img src="http://p0.so.qhimgs1.com/bdr/_240_/t0179f4988b0dcd926c.jpg"><br>

     </div>
</div>
</body>
</html>
img {
     180px;
    height: auto;
    float: left;
        }
.img{
    border: 2px solid #ccc;
     180px;
    float: left;
    padding: 30px;
     height: auto;
    margin: 30px;
}
div.img img{
     100%;
    height: auto;
     padding: 20px;

}
div.desc{
    text-align: center;
    padding: 20px;
}
div.img:hover{
    border: 1px solid #110000;
}
div clearfloat{
clear: both;
}
 
  1. 认识CSS的 盒子模型。
  2. CSS选择器的灵活使用。
  3. 实例:
    1. 图片文字用div等元素布局形成HTML文件。
    2. 新建相应CSS文件,并link到html文件中。
    3. CSS文件中定义样式
      1. div.img:border,margin,width,float
      2. div.img img:width,height
      3. div.desc:text-align,padding
      4. div.img:hover:border
      5. div.clearfloat:clear
原文地址:https://www.cnblogs.com/YyYyYy11/p/7698044.html