目录
常用选择器
id选择器:#id
类选择器:.class
关系选择器:div p、div>p、div,p ...
伪类选择器:hover、active、link ...
结构性伪类选择器:E:before、E:after、E:nth-chlid、E:first-child、E:last-child、E:nth-of-type ...
div p 选中div内所有p元素(包括孙子辈)
div > p 选中div内所有p元素(孙子辈不算)
div,p 选中div和p元素
div+p选中div后的第一个兄弟p元素(必须相邻,兄弟辈)
div~p选中div后的所有兄弟p元素(兄弟辈)
div.container选中含有class="container"的div元素
常用属性(1)
字体属性:font-size、font-family、font-weight、font-style
文本属性:text-decoration、text-align
首行缩进:text-indent
行高:line-height
宽高属性:width、height、min-height、max-height
背景属性:background
列表属性:list-style
字体颜色:color
常用属性(2)
定位属性:position
布局属性:display
浮动属性:float、clear
盒子属性:padding、margin、border
圆角属性:border-radius
阴影:box-shadow、text-shadow
box-sizing: border-box(怪异盒子模型)实际宽度就是width
box-sizing: content-box(标准盒子模型)实际宽度为width+padding+border
display属性
1.none隐藏元素
2.inline内联元素
3.block块元素
4.inline-block内联块元素
5.table-cell表格单元格
6.flex弹性盒子
行内元素不能设置宽和高,但不会独占一行(在默认情况下)
块元素可以设置宽和高,但独占一行(在默认情况下)