码迷,mamicode.com
首页 > Web开发 > 详细

CSS实例:图片导航块

时间:2017-10-20 18:37:19      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:static   over   .com   desc   center   height   stat   选择器   ati   

  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
        <!DOCTYPE html>
        <html lang="en">
        <head>
            <meta charset="UTF-8">
            <title>大疆(DJI)无人机</title>
            <link rel="stylesheet" type="text/css"href="../static/css/wh.css">
        </head>
        <body>
        
            <div>
                <div class="img">
                    <a href="http://www.dji.com/cn">
                      <img src="https://img14.360buyimg.com/n7/jfs/t5977/17/185587587/108108/247ade15/5925b821N32b8bb9a.jpg"></a>
                  <div class="desc"><a href="http://www.dji.com/cn">大疆“晓”Spark</a></div>
        
               </div>
                <div class="img">
                <a href="http://www.dji.com/cn">
                      <img src="https://img10.360buyimg.com/n7/jfs/t3232/65/6215650755/81612/3a052265/58a27e59N05fb5fc2.jpg" ></a>
                  <div class="desc"><a href="http://www.dji.com/cn">大疆“精灵”Phantom</a></div>
        
            </div>
                <div class="img">
                <a href="http://www.dji.com/cn">
                      <img src="https://img14.360buyimg.com/n7/jfs/t4012/34/459557656/48075/11cf82d3/584fcc5cN056eb123.jpg" ></a>
                  <div class="desc"><a href="http://www.dji.com/cn">大疆“御”Mavic Pro</a></div>
        
        
            </div>
                <div class="img">
                <a href="http://www.dji.com/cn">
                      <img src="https://img10.360buyimg.com/n7/jfs/t2278/130/1443161174/71119/87b96780/565edd23N23d203bc.jpg"></a>
                  <div class="desc"><a href="http://www.dji.com/cn">大疆“悟”Inspire</a></div>
        
        
            </div>
        
        
        </div>
        
        
        
        
        
        <div class="clearfloat">
              <img src="https://img14.360buyimg.com/n7/jfs/t5977/17/185587587/108108/247ade15/5925b821N32b8bb9a.jpg">
              <img src="https://img10.360buyimg.com/n7/jfs/t3232/65/6215650755/81612/3a052265/58a27e59N05fb5fc2.jpg">
              <img src="https://img14.360buyimg.com/n7/jfs/t4012/34/459557656/48075/11cf82d3/584fcc5cN056eb123.jpg">
              <img src="https://img10.360buyimg.com/n7/jfs/t2278/130/1443161174/71119/87b96780/565edd23N23d203bc.jpg">
        
        </div>
        </body>>
        img{
            width: 250px;
            height: 250px;
        }
        div.img{
            border: 1px solid black;
            width: 300px;
            height: 300px;
            float: left;
            margin: 5px;
        }
        div.img img{
            width: 100%;
            height: 80%;
        }
        div.desc{
            text-align: center;
            padding: 5px;
        }
        div.img:hover{
            border: 2px solid cornflowerblue;
        }
        .clearfloat{
            clear:both;
        }

        技术分享

CSS实例:图片导航块

标签:static   over   .com   desc   center   height   stat   选择器   ati   

原文地址:http://www.cnblogs.com/marsk/p/7700212.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!