首页 > Web开发 > 详细

CSS实例:图片导航块

时间:2017-10-20 20:54:24      阅读:199      评论:0      收藏:0      [点我收藏+]
  • 认识CSS的 盒子模型。
  • CSS选择器的灵活使用。
  • 实例:
    1. 图片文字用div等元素布局形成HTML文件。
    2. 新建相应CSS文件,并link到html文件中。
    3. CSS文件中定义样式
    4. div.img:border,margin,width,float
    5. div.img img:width,height
    6. div.desc:text-align,padding
    7. div.img:hover:border
    8. div.clearfloat:clear
      <!DOCTYPE html>
       <html lang="en">
        <head>
            <meta charset="UTF-8">
            <title>img</title>
            <link rel="stylesheet" type="text/css" href="../static/css/wu.css">
        </head>
        <body>
        <div class="recommend">
           <div class="img">
               <a hrefclas="http://www.gzcc.cn"><img src="http://static.runoob.com/images/demo/demo4.jpg" ></a>
               <div class="desc"><a href="http://www.gzcc.cn">校园风光</a></div>
           </div>
           <div class="img">
               <a href="http://www.gzcc.cn"><img src="http://static.runoob.com/images/demo/demo3.jpg" ></a>
               <div class="desc"><a href="http://www.gzcc.cn">校友风采</a></div>
           </div>
           <div class="img">
               <a href="http://www.gzcc.cn"><img src="http://static.runoob.com/images/demo/demo2.jpg" ></a>
               <div class="desc"><a href="http://www.gzcc.cn">学样文化</a></div>
           </div>
           <div class="img">
               <a href="http://www.gzcc.cn"><img src="http://static.runoob.com/images/demo/demo1.jpg" ></a>
               <div class="desc"><a href="http://www.gzcc.cn">学生风采</a></div>
           </div>
       </div>
       <br>
       <div class="clearfolat">
           <img src="http://static.runoob.com/images/demo/demo4.jpg">
           <img src="http://static.runoob.com/images/demo/demo3.jpg">
           <img src="http://static.runoob.com/images/demo/demo2.jpg">
           <img src="http://static.runoob.com/images/demo/demo1.jpg">
       </div>
      
       </body>
       </html>
      技术分享

      css

      技术分享
      img {
            width: 300px;
       }
        div.img{
            border:1px solid #cccccc;
            float: left;
           margin: 5px;
            width:180px;
       }
       div.img img{
           width:100%;
           height:auto;
       }
       div.desc{
          text-align: center;
           padding: 5px;
       }
       div.img:hover{
            border:1px solid #000000;
       }
       div.clearfolat{
           clear: both;
       }




      技术分享

       

      
      

CSS实例:图片导航块

原文:http://www.cnblogs.com/Carrie-chong/p/7697919.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!