首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >居中位置:固定图元

居中位置:固定图元
EN

Stack Overflow用户
提问于 2010-01-05 20:29:00
回答 18查看 707.5K关注 0票数 513

我想使一个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在屏幕上居中显示此框?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2005954

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档