<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
/* div{
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
width: 100px;
height: 100px;
background-color: red;
} */
/* div{
top: 50%;
left:50%;
transform: translate(-50%,-50%);
position: absolute;
width: 100px;
height:100px;
background-color: gold;
} */
div{
position: absolute;
top: 50%;
left:50%;
margin-left: -50px;
margin-top: -50px;
width: 100px;
height:100px;
background-color: blue;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交