CSS实例:图片导航块

  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>火星情报局</title>
            <link rel="stylesheet" type="text/css"href="jjj.css">
        </head>
        <body>
        <div>
                <div class="img">
                    <a href="https://baike.baidu.com/item/%E5%8D%8E%E6%99%A8%E5%AE%87/6064097?fr=aladdin">
                        <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2330928080,25031233&amp;fm=27&amp;gp=0.jpg"></a>
                  <div class="desc"><a href="https://baike.baidu.com/item/%E5%8D%8E%E6%99%A8%E5%AE%87/6064097?fr=aladdin">华晨宇百度百科</a></div>
        
                    <div class="img">
                    <a href="http://music.163.com/#/artist?id=861777&market=baiduqk">
                        <img src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3605928156,2200570185&amp;fm=27&amp;gp=0.jpg"></a>
                  <div class="desc"><a href="http://music.163.com/#/artist?id=861777&market=baiduqk">华晨宇的歌</a></div>
        
                        <div class="img">
                    <a href="http://www.iqiyi.com/v_19rrkcz1o8.html">
                        <img src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2787456122,2827006597&amp;fm=27&amp;gp=0.jpg"></a>
                  <div class="desc"><a href="http://www.iqiyi.com/v_19rrkcz1o8.html">华晨宇歌声惊呆EXO</a></div>
        
                            <div class="img">
                    <a href="http://www.iqiyi.com/w_19rrly19c5.html">
                        <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2478028302,36965079&amp;fm=27&amp;gp=0.jpg"></a>
                  <div class="desc"><a href="http://www.iqiyi.com/w_19rrly19c5.html">华晨宇快男赛程回顾</a></div>
        <div class="clearfloat">
             <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2330928080,25031233&amp;fm=27&amp;gp=0.jpg">
             <img src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3605928156,2200570185&amp;fm=27&amp;gp=0.jpg">
             <img src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2787456122,2827006597&amp;fm=27&amp;gp=0.jpg">
             <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2478028302,36965079&amp;fm=27&amp;gp=0.jpg">
        </body>
        </html>


        CSS  img{  width: 300px;
                }
          div.img{
                  border: 1px solid burlywood;
                  width:200px;
                  height: 200px;
                  float: left;
                  margin: 5px;
              }
              div.img img{
                  width: 100%;
                  height: 85%;
              }
              div.desc{
                  text-align: center;
                  padding: 5px;
              }
              div.img:hover{
                  border: 2px solid greenyellow;}
        
                div.clearfolat{
                       clear: both;
                  solid-color: black;
              }

posted @ 2017-10-20 21:24  073徐英杰  阅读(152)  评论(0编辑  收藏  举报