<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<style>
/*方法一*/
/*.box{
width:300px;
height:300px;
border:1px solid #ff0;
position:relative;
}
.box1{
width:100px;
height:100px;
background: deepskyblue;
position:absolute;
left:0;
right:0;
top:0;
bottom: 0;
margin:auto;
}*/
/*方法二*/
/*.box{
width:300px;
height:300px;
border:1px solid #ff0;
position:relative;
}
.box1{
width:100px;
height:100px;
background: deepskyblue;
position:absolute;
left:50%;
margin-left:-50px;
top:50%;
margin-top: -50px;
}*/
/*方法三*/
/*.box{
width:300px;
height:300px;
border:1px solid #ff0;
position:relative;
}
.box1{
width:100px;
height:100px;
background: deepskyblue;
position:absolute;
left:50%;
top:50%;
transform: translate(-50%,-50%);
}*/
/*方法四*/
.box{
width:300px;
height:300px;
border:1px solid #ff0;
display:flex;
justify-content: center;
align-items: center;
}
.box1{
width:100px;
height:100px;
background: deepskyblue;
}
</style>
<body>
<div class="box">
<div class="box1"></div>
</div>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<style>
/*方法一*/
/*.box{
width:300px;
height:300px;
border:1px solid #ff0;
position:relative;
}
.box1{
width:100px;
height:100px;
background: deepskyblue;
position:absolute;
left:0;
right:0;
top:0;
bottom: 0;
margin:auto;
}*/
/*方法二*/
/*.box{
width:300px;
height:300px;
border:1px solid #ff0;
position:relative;
}
.box1{
width:100px;
height:100px;
background: deepskyblue;
position:absolute;
left:50%;
margin-left:-50px;
top:50%;
margin-top: -50px;
}*/
/*方法三*/
/*.box{
width:300px;
height:300px;
border:1px solid #ff0;
position:relative;
}
.box1{
width:100px;
height:100px;
background: deepskyblue;
position:absolute;
left:50%;
top:50%;
transform: translate(-50%,-50%);
}*/
/*方法四*/
.box{
width:300px;
height:300px;
border:1px solid #ff0;
display:flex;
justify-content: center;
align-items: center;
}
.box1{
width:100px;
height:100px;
background: deepskyblue;
}
</style>
<body>
<div class="box">
<div class="box1"></div>
</div>
</body>
</html>
1190

被折叠的 条评论
为什么被折叠?



