码迷,mamicode.com
首页 > Web开发 > 详细

html引入css的方法,以及css选择器

时间:2017-12-31 22:29:59      阅读:344      评论:0      收藏:0      [点我收藏+]

标签:.class   log   内嵌   标签   交集   style   port   body   class   

Html中引入css的四种方式

1、行内式

style=“XXX”写在标签中

<h1 style = "color: #000;">

2、内嵌式

把style标签写在head标签中

<style>
    h1{color: #000;}
</style>

3、导入式

在style标签中使用@import=“css_File”

<style>
    @import"style.css"
</style>

4、链接式

使用link标签和href=“css_File”

<link rel="stylesheet" href="style.css" type="" media=""/>

 

css的基本选择器

1、标签选择器:tagName{}

2、类别选择器:.className{}

3、ID选择器:#idName{}

4、通配符:*{}表示页面内的所以元素

css复合选择器(权限:直连>空格>逗号)

1、交集选择:中间没空格(基本选择器之间)

表示前后多个选择器都满足

2、并集选择:用逗号(",")隔开(基本选择器之间)

表示前后多个选择器满足其中一个

3、后代选择:用空格(" ")隔开(基本选择器之间)

表示前者中的后者

css中的优先级

style行内>#id样式>.class样式>tag样式

html引入css的方法,以及css选择器

标签:.class   log   内嵌   标签   交集   style   port   body   class   

原文地址:https://www.cnblogs.com/thinline/p/8158842.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!