css样式表和选择器

1.行内样式

<p style="color:white;background-color:red">啦啦啦啦啦</p>

2.内嵌样式表

<style type="text/css">
    p {
        font-weight: bold;
        font-style: italic;
        color: red;
    }
</style>

<body>
    <p>洗白白</p>
    <p style="color:blue">啦啦啦</p>
</body>

3.引入外部样式表

<link rel = "stylesheet" type = "text/css" href = "a.css"></link>

4.标签选择器

p{ font-size:14px; }

所有p标签都将显示14号字体

5.id选择器

#mytitle{ border:3px dashed green; }

6.类选择器

.one{ width:800px; }

7.后代选择器(有空格)

div p {color: red;}

8.交集选择器(没有空格)

h3h4p {color: red;}

9.并集选择器

p,h1,#mytitle,.one {color: red;}

10.子代选择器

div > p {color: red;}

11.序选择器

 ul li:first-child {color: red;}

12.伪类选择器

同一个标签,根据其不同的状态,拥有不同的样式,这就叫做伪类选择器

12.1 静态伪类只能用于超链接的样式

:link 链接点击之前

:visited 链接点击之后

12.2 动态伪类针对所有标签都适用的样式

:hover 悬停:当鼠标放在标签上的时候

:active 激活: 当鼠标点击标签,但不松手

:focus 某个标签获得焦点时

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值