我想使一个position: fixed;
弹出框居中的屏幕与动态的宽度和高度。为此,我使用了margin: 5% auto;
。如果没有position: fixed;
,它可以水平居中,但不能垂直居中。添加position: fixed;
后,它甚至不会水平居中。
以下是完整的设置:
.jqbox_innerhtml {
position: fixed;
width: 500px;
height: 200px;
margin: 5% auto;
padding: 10px;
border: 5px solid #ccc;
background-color: #fff;
}
<div class="jqbox_innerhtml">
This should be inside a horizontally
and vertically centered box.
</div>
如何使用CSS在屏幕上居中显示此框?
https://stackoverflow.com/questions/2005954
复制相似问题