CSS基础学习7-CSS设置组织元素(span和div)

所有CSS基础学习文档下载地址:http://download.csdn.net/detail/rongrong_love_lc/9663463

七、CSS设置组织元素(span和div)
    span和div元素用于组织和结构化文档,并经常联合class和id属性一起使用。
    span使用局限在一个块元素内。
    1.用span组织元素:
        span元素是一种中性元素,因为他不对文档本身添加任何东西。但是与CSS结合使用的话,span可以对文档中的不分文本添加视觉效果。
    html文件如下:
      <html>
            <head>
                 <title>Color例子</title>
                 <link rel="stylesheet" type="text/css" href="color.css"/>
             </head>
             <body>
                 <p>study测试文本信息study</p>
                 <h1 >study<span class="green">测试文本信息1</span>study</h1>
                 <h2 >study<span class="black">测试文本信息2</span>study</h2>
                 <h3 >study<span class="yellow">测试文本信息3</span>study</h3>
             </body>
           </html>
      CSS文件如下:
           body {background:white url("image1.jpg") no-repeat fixed center;
               }
           p {text-align:justify;
              letter-spacing:5px;
              text-transform:none;}
           span.green {color:green;
                       text-decoration:underline;}
           span.black {color:black;
                       text-decoration:underline;}
           span.yellow {color:yellow;
                        text-decoration:underline;}
    2.用div组织元素:
        div可以被用来组织一个或者多个块的元素。
      html文件如下:
        <html>
              <head>
                 <title>Color例子</title>
                 <link rel="stylesheet" type="text/css" href="color.css"/>
               </head>
               <body>
             <p> <div id="ddd">测试信息1</div></p>
             <ul>
                <li><a href="https://www.baidu.com" class="green">百度一下1</a></li>
                <li><a href="https://www.sogou.com" class="yellow">搜狗1</a></li>
                <li><a href="http://translate.google.cn" class ="red">谷歌翻译1</a></li>
               <li><a href="http://fanyi.youdao.com" class="black">有道翻译1</a></li>
             </ul>
             <p>测试信息2</p>
             <div id = "ddd">
                 <ul>
                    <li><a href="https://www.baidu.com">百度一下2</a></li>
                    <li><a href="https://www.sogou.com">搜狗2</a></li>
                    <li><a href="http://translate.google.cn">谷歌翻译2</a></li>
                    <li><a href="http://fanyi.youdao.com">有道翻译2</a></li>
                 </ul>
             </div>
               </body>
          </html>
    CSS文件如下:
      body {background:white url("image1.jpg") no-repeat fixed center;
        }
      p {text-align:justify;
         letter-spacing:5px;
         text-transform:none;}
      a.green {color:green;
               text-decoration:underline;}
      a.black {color:black;
           text-decoration:underline;}
      a.yellow {color:yellow;
            text-decoration:underline;}
      a.red {color:red;
             text-decoration:underline;}
      #ddd {background-color:#AABBCC;
        color:red;}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值