常用 css 居中

/*定位上下左右居中*/
.center {
	position: absolute;
	top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/*定位上下居中*/
.ct {
	position: absolute;
	top: 50%;
    transform: translateY(-50%);
}

/*定位左右居中*/
.cl {
	position: absolute;
	left: 50%;
    transform: translateX(-50%);
}

.flex-x-center{
  display: flex;
  justify-content: center;
}

.flex-y-center{
  display: flex;
  align-items: center;
}

猜你喜欢

转载自blog.csdn.net/qq_35397218/article/details/82983436