相关疑难解决方法(0)

中心位置:固定元素

我想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;
}
Run Code Online (Sandbox Code Playgroud)
<div class="jqbox_innerhtml">
    This should be inside a horizontally
    and vertically centered box.
</div>
Run Code Online (Sandbox Code Playgroud)

如何使用CSS将此框置于屏幕中心?

css css-position centering

399
推荐指数
9
解决办法
54万
查看次数

标签 统计

centering ×1

css ×1

css-position ×1