1 标签的分类
1.块元素 block :独占一行,可设置宽高
2.行元素 inline :不独占一行,设置宽高无效
3.行内块元素 inline—block :不独占一行,可设置宽高
2 css三种引用方式
1.内联式(行内样式):<div style="color:red;">hello</div>
2.内嵌式 <style> div{font-family:"楷体"; }</style>
3.外引式 <link rel="stylesheet" href="./index.css">
3 常用的选择器
1.* 通配符 选中页面中所有的标签
2.div 标签选择器 页面中所有的div
3.class .box 页面中类型是box的所有标签
4.id #box 页面中id为box的标签
4 常用文字样式
/*字体类型*/ • font-family: "楷体"; • /*字体颜色*/ • color: pink; • /*字体大小*/ • font-size: 40px; • /*字体加粗100-900*/ • font-weight: 100; • /*字体倾斜*/ • font-style: italic; • /*文本对齐*/ • text-align: center; • /*文本修饰*/ • text-decoration:underline; • /*首行缩进*/ • text-indent: 4em; • /*capitalize首字母大写 lowercase首字母小写 uppercase大写*/ • text-transform: uppercase; • /*字母或中文间距*/ • letter-spacing: 30px; • /*字母间距*/ • word-spacing: 30px; • /*行高 行间距*/ • line-height: 50px;
5 css优先级
!important > 行内样式 > id > class > tag > * > 继承(父元素样式)
权重 无穷大 1000 100 10 1 0 无
-
如果优先级相同,就近原则
注意:不是所有有的样式都可以继承,继承的多是颜色字体样式等
~~~
6 css选择器组合使用
-
子代 ">"
-
后代 " "(英文空格)
-
并列 ","
7 css匹配规则
-
从右到左