用calc 实现水平垂直居中
作者:
宏_4491 | 来源:发表于
2020-09-30 09:49 被阅读0次<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
.box{
position: relative;
height: 400px;
width: 400px;
background-color: pink;
}
.box2{
height: 100px;
width: 100px;
background-color: skyblue;
position: absolute;
left: calc(50% - 50px);
top: calc(50% - 50px);
}
</style>
<body>
<div class="box">
<div class="box2"></div>
</div>
</body>
</html>
image.png
本文标题:用calc 实现水平垂直居中
本文链接:https://www.haomeiwen.com/subject/kbbyuktx.html
网友评论