基础属性
1.显示模式display
1.块级元素:
block(一整行)
2.行内元素:
inline(一小块)
3.行内块元素:
inline-block(相比于2而言可以自己设高度)
4.flex
5.grid
2.基础属性一类
2.1.背景
1.背景图片(image)
background-image: url(#) || none;
2.背景平铺(repeat)
background-repeat: no-repeat || repeat-x || repeat-y || repeat;
3.背景位置(position)[重点]
background-position: x y || top/center/bottom/left/right
4.背景附着(解释背景是滚动的还是固定的)
background-attachment: scroll(默认滚动) || fixed(固定)
5.背景颜色
background-color: color || transparent;
6.背景简写
background: 颜色 图片地址 平铺 滚动 位置;
7.背景透明
background: rgba(红,绿,蓝,透明度0~1);
2.2.字体
1.font-size{ 字体大小 }
//谷歌默认大小为16px
//1em的默认大小是16px。可以通过下面这个公式将像素转换为em:px/16=em
2.font-family{ 字体样式 }//一般都是默认不修改,除非甲方提出要求
3.font-style{ 字体风格 }//倾斜italic
4.font-weight{ 字体粗细 }// normal:400、bold:700、一般100~900直接写
font : font-style font-weight font-size font-family;
2.3.文本段落
color:文本颜色
line-height:行间距
text-align:文本水平对齐方式
text-indent:首行缩进 nem(n个字的距离)
text-decoration:文本的装饰
//无装饰 none || 闪烁blink || 下划线underline || 贯穿线line-through || 上划线overline
//对于W3C标准的CSS:如果你定义了颜色属性,你还必须定义背景色属性
3.CSS三大特性
1.层叠性
长江后浪推前浪,前浪浪没了
2.继承性
子标签会继承父标签的属性(text- , font- , line- ,color这些属性可以继承)
3.优先级(重点)
3.1.如果选择器相同,则执行层叠性
3.2.如果选择器不同,则执行优先级规则:
继承或* < 标签选择器 < 类选择器 < id选择器 < 行内样式表 < !important(样式属性后添加,最高)