CSS3效果:兩種方法實現盒子居中----以“回”字為例


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
*{
padding:0;
margin:0;
}
.box1 {
position: absolute;
top: 50%;
left: 50%;
width: 400px;
height: 300px;
border: 50px solid #000;
margin: -200px auto auto -250px;
}
.box2{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
width: 150px;
height: 100px;
border: 50px solid #000;
}
</style>
</head>
<body>
<div class="box1">
<div class="box2">
</div>
</div>
</body>
</html>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM