CSS常用记忆

  1. padding的顺序 上、右、下、左(顺时针)
    margin和padding的区别
    margin是设置盒子边界(例如div)到父元素边界的距离,padding是设置盒子内部的元素距离盒子边界的距离https://www.jianshu.com/p/73deb2ae7992
  2. 快速生成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>
  1. 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;
}
  1. 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标签没有语义,只是为了给内容设置单独的样式用的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值