- padding的顺序 上、右、下、左(顺时针)
margin和padding的区别
margin是设置盒子边界(例如div)到父元素边界的距离,padding是设置盒子内部的元素距离盒子边界的距离https://www.jianshu.com/p/73deb2ae7992 - 快速生成html头,在.html中输入!按下tab键补全
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
</body>
</html>
- div元素内文字水平垂直居中
- 单行文本水平垂直居中(用于div内文本水平垂直居中)
div{
height: 40px;
line-height: 40px; // line-height和height一样即可垂直居中,有一个弊端当文本宽度超出div的宽度时,文本会脱离div
text-align: center; // 水平居中
}
- 多行文本垂直居中
方法1:在div中插入table,vertical-align属性即可生效
方法2:缺点是改变了div的块状属性,IE6、7不支持
div{
display: table-cell;
vertical-align: middle;
}
- div居于父div中间(垂直方向)
方式1:使用flex布局
.father {
width: 500px;
height: 500px;
display: flex;
justify-content: center; // 水平居中(主轴方向)
align-items: center; // 垂直居中(交叉轴方向)
flex-direction: row // 主轴方向:默认row(向右),向下:flex-direction: column,向左:flex-direction: row-reverse,向上:flex-direction: column-reverse
background-color: red;
}
.son {
width: 200px;
height: 200px;
background-color: black;
}
https://blog.csdn.net/aliguagua/article/details/78178124
6. span标签没有语义,只是为了给内容设置单独的样式用的。