目录

3.12-3-html

目录

3.12-3 html

css层叠样式

层叠样式

(1)定义:css是一种用来表现html或xml等文件样式的计算机语言。

(2)css 不仅可以静态的修饰网页,还可以配合各种动态对网页元素进行格式化;

(3)层叠样式表有两种方法:

第一种:在head中加上style属性

https://i-blog.csdnimg.cn/img_convert/1119520e0caa0c062d4505c648054b97.png

代码:

案例:

层叠样式

1

2

3

a

i

标题

第二种:通过外链方式

在css中新建一个css文件,在css文件中写内容

https://i-blog.csdnimg.cn/img_convert/81a6758687e62962ec164fec9773c02f.png

https://i-blog.csdnimg.cn/img_convert/88d161a8b5d6c1ae62d978080e411125.png

https://i-blog.csdnimg.cn/img_convert/3e490f21e11a03caf3c599aee79e700f.png

在使用link 通过外链方式实现

https://i-blog.csdnimg.cn/img_convert/9613def8d3c054ac8a6aa6ffa2e8be99.png

代码:

层叠样式

1

2

3

a

i

标题

二、选择器

https://i-blog.csdnimg.cn/img_convert/b3c334fcdb07f0bfd49cbb89e09e64a3.png

(1)id选择器 # id

代码:

层叠样式

1

2

3

a

i

标题

https://i-blog.csdnimg.cn/img_convert/c514c7efa739548657f3a501e8dfaba8.png

https://i-blog.csdnimg.cn/img_convert/c9e13f79c8a18040853963b2208408cc.png

(2)class选择器(.)

https://i-blog.csdnimg.cn/img_convert/cd535f2549972c04a69afd768ee6362b.png

(3)标签选择器

比如:i 标签

https://i-blog.csdnimg.cn/img_convert/4ba3869cdd0863edb55c381dd04d7ca1.png

(4)组合标签

https://i-blog.csdnimg.cn/img_convert/457cee1b1d6aa74abc27c020ceefefea.png

(5)伪类选择器

层叠样式

1

2

3

a

i

标题

https://i-blog.csdnimg.cn/img_convert/95c5e1cbff486e122449c7596b42fdd9.png

三、层叠样式中的内容可以多样化

https://i-blog.csdnimg.cn/img_convert/ce5e32097256bb08f9a25217f2884742.png

层叠样式

1

2

3

a

i

标题