让一个div居中显示在浏览器页面中
<body>
<div id="box"></div>
</body>
<style>
*{padding:0;margin:0;}
#box{
background-color:black;
height:80%;width:80%;
position:fixed;
top:0;right:0;bottom:0;left:0;
margin:auto;
}
</style>
显示效果(如下图所示)
<body>
<div id="box"></div>
</body>
<style>
*{padding:0;margin:0;}
#box{
background-color:black;
height:80%;width:80%;
position:fixed;
top:0;right:0;bottom:0;left:0;
margin:auto;
}
</style>
显示效果(如下图所示)