CSS实例:图片导航块

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

    <div>
        <div class="img">
            <a href="http://pal4.roogames.com/">
                <img src="http://pal4.roogames.com/pal4/pal4index_files/pic/pic_d_22.jpg"></a>
            <div class="desc"><a href="http://pal4.roogames.com/">慕容紫英</a></div>
       </div>
        <div class="img">
        <a href="http://pal4.roogames.com/">
            <img src="http://pal4.roogames.com/pal4/pal4index_files/pic/pic_d_23.jpg">
        </a>
        <div class="desc"><a href="https://baike.baidu.com/item/%E4%BA%91%E5%A4%A9%E6%B2%B3/11894?fr=aladdin">云天河</a> </div>
    </div>
        <div class="img">
        <a href="http://pal4.roogames.com/">
            <img src="http://pal4.roogames.com/pal4/pal4index_files/pic/pic_24.jpg">
        </a>
        <div class="desc"><a href="http://pal4.roogames.com/">柳梦璃</a> </div>
    </div>
        <div class="img">
        <a href="http://pal4.roogames.com/">
            <img src="http://pal4.roogames.com/pal4/pal4index_files/pic/pic_03.jpg">
        </a>
        <div class="desc"><a href="http://pal4.roogames.com/">韩菱纱</a> </div>
    </div>


</div>





<div class="clearfloat">
      <img src="http://pal4.roogames.com/pal4/pal4index_files/pic/pic_d_22.jpg">
      <img src="http://pal4.roogames.com/pal4/pal4index_files/pic/pic_d_23.jpg">
      <img src="http://pal4.roogames.com/pal4/pal4index_files/pic/pic_24.jpg">
      <img src="http://pal4.roogames.com/pal4/pal4index_files/pic/pic_03.jpg">

</div>
</body>>
</html>
 img{
     300px;
}
div.img{
    border: 1px solid seagreen;
     180px;
    float: left;
    margin: 5px;
}
div.img img{
     100%;
    height: auto;
}
div.desc{
    text-align: center;
    padding: 5px;
}
div.img:hover{
    border:1px solid blue;
}
.clearfloat{
    clear: both;

}

原文地址:https://www.cnblogs.com/0055sun/p/7699375.html