HTML 标签分类

标签分类

  1.块元素

典型代表,Div,h1-h6,p,ul,li

特点: ★独占一行

        ★可以设置宽高

        ★ 嵌套(包含)下,子块元素宽度(没有定义情况下)和父块元素宽度默认一致。

 

2.  行内元素

典型代表 span  ,a,  ,strong , em,  del,  ins

特点:★在一行上显示

         ★不能直接设置宽高

         ★元素的宽和高就是内容撑开的宽高。

div,p{
display:inline;
width:500px;
height:500px;
background-color:red;
}

 

 

3.   行内块元素(内联元素)

典型代表  input  img

特点:★在一行上显示

        ★可以设置宽高

 

 

 

4.  块元素、行内元素

◆块元素转行内元素

display:inline;

 

 

◆行内元素转块元素

display:block;

 

 

◆块和行内元素转行内块元素

display:inline-block;

 

 

 

 

 css三大特性

1   层叠性

当多个样式作用于同一个(同一类)标签时,样式发生了冲突,总是执行后边的代码(后边代码层叠前边的代码)。和标签调用选择器的顺序没有关系。

 

    .box{
        font-size:60px;
        color:red;
    }
    .box2{
        font-size:200px;
        color:blue;
    }

    </style>

</head>
<body>
    
    <div  class="box  box2">kadfaklsdfa</div>
    <p>askdlfjalwdfwe</p>
</body>

 

2    继承性

   继承性发生的前提是包含(嵌套关系)

   ★文字颜色可以继承

   ★文字大小可以继承

   ★字体可以继续

   ★字体粗细可以继承

   ★文字风格可以继承

   ★行高可以继承

   总结:文字的所有属性都可以继承。

◆特殊情况:

h系列不能继承文字大小。

a标签不能继承文字颜色。

 

3  优先级
 默认样式<标签选择器<类选择器<id选择器<行内样式<!important  

 0               1                   10              100          1000      1000以上

◆优先级特点

★继承的权重为0

★权重会叠加

    <link rel="text/css" />
    <style>
    .bz{
        display:inline;
        width:500px;
        height:500px;
        background-color:red;
    }
    .box{
        font-size:60px;
        color:red;
    }
    .box2{
        font-size:200px;
        color:blue;
    }
    #box3{
        font-size:300px;
        color:green;
    }
/*     div{
        color:red !important;
        font-size:20px;
    } */
    </style>

</head>
<body>
    
    <div  class="box  box2"  id="box3">kadfaklsdfa</div>
    <p>askdlfjalwdfwe</p>

 

综  合

<html>
    <head>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />
        <meta name="keywords" content="关键词1,关键词2,关键词3" />
        <meta name="description" content="对网站的描述" />
        <title>第1题</title>
        <style type="text/css">

            
            #father #son{  
                color:blue;          //权重:100+100=200
            }
            
            #father p.c2{            //权重:100+1+10=111
                color:black;
            }

        </style>
    </head>
    <body>
        <div id="father" class="c1">
            <p id="son" class="c2">
                试问这行字体是什么颜色的?
            </p>
        </div>
    </body>
</html>

 

 

<html>
    <head>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />
        <meta name="keywords" content="关键词1,关键词2,关键词3" />
        <meta name="description" content="对网站的描述" />
        <title>第3题</title>
        <style type="text/css">
            
            div p{   
                color:red;            //权重 :2
            }
            #father{
                color:red;            //权重:0
            }
            p.c2{    
                color:blue;          //权重:11
            }
        </style>
    </head>
    <body>
        <div id="father" class="c1">
            <p class="c2">
                试问这行字体是什么颜色的?
            </p>
        </div>
    </body>
</html>

 

posted @ 2017-03-28 09:43  yimian  阅读(272)  评论(0编辑  收藏  举报
访问人数:AmazingCounters.com