<html>
<head>
<title>absolute设置区块绝对居中</title>
<style>
#one {
height:200px;
width:300px;
background:#FF0000;
position:absolute;
left:50%;
top:50%;
margin-left:-100px;
margin-top:-150px;
</style>
</head>
<body>
<DIV id="one">
</DIV>
</body>
</html>
本文介绍了一种使用CSS绝对定位实现元素居中的方法。通过将元素的位置设为绝对,并结合left、top属性与margin调整,使区块在页面中水平垂直居中显示。
680

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



