前端一HTML:十三:css的三大特性

1. 继承

    给父元素设置一个属性,然后子元素可以使用.

  凡是以 line-,text-,font-开头的属性都是可以继承。

2. 层叠

   是页面处理冲突属性的一个能力

  如果两个选择器为同一个元素设置了不同的属性,它们会同时作用于这个元素。

  如果两个选择器为同一个元素设置了相同的属性,它们会发生层叠。(层叠的结果跟优先级有关系)

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        .one{
            font-style: italic;
            color:blue;
        }
        div{
            font-size: 30px;
            color:red;
        }
    </style>
</head>
<body>
    <div class="one" id="one">
        abc
    </div>
</body>
</html>

3. 优先级

   优先级从大到小排列:  !important属性 > id选择器 > 类选择器 > 标签选择器>通配符>继承>浏览器默认

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        #one{
            color: pink;
        }

        .one{
            font-style: italic;
            color:blue;
        }
        div{
            font-size: 30px;
            color:red;
        }

        .father {
            color: yellow;
        }

        * {
            color: purple;
        }
    </style>
</head>
<body>
    <div class="father">
        <div class="one" id="one">
            abc
        </div>
    </div>
</body>
</html>

  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值