<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no"/>
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
#box{
width:400px;
height:600px;
background-color: aquamarine;
margin:auto;
position: relative;
}
#inter{
width: 100px;
height:100px;
background-color: red;
position: absolute;
left:0;
top:0;
right: 0;
bottom: 0;
margin: auto;
}
</style>
</head>
<body>
<div id="box">
<div id="inter">
hhh<br>
</div>
</div>
</body>
</html>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
#box{
width:400px;
height:600px;
background-color: aquamarine;
margin:auto;
position: relative;
}
#inter{
width: 100px;
height:100px;
background-color: red;
position: absolute;
left:50%;
top:50%;
margin-left:-50px;
margin-top:-50px;
}
</style>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
#box{
width:400px;
height:600px;
background-color: aquamarine;
margin:auto;
position: relative;
}
#inter{
width: 100px;
height:100px;
background-color: red;
position: absolute;
left: 50%;
top:50%;
transform: translate3d(-50%,-50%,0);
}
</style>