简体   繁体   English

在Bootstrap 3中垂直居中div元素

[英]Center div element vertically in Bootstrap 3

Basically this has been bugging me all morning. 基本上,这整个上午一直困扰着我。 I've looked at plenty of other threads but none seem to help me out which is why I'm creating this question. 我看过很多其他主题,但似乎没有一个对我有帮助,这就是为什么我要创建这个问题。

I simply want to center my div element on my bootstrap page. 我只是想将div元素居中在我的引导页面上。 It seems like a simple issue but I just cannot fix it. 这似乎是一个简单的问题,但我无法解决。

Html: HTML:

<div class="wizard-box"></div>

Css: CSS:

.wizard-box {
    background-color: green;
    height: 300px;
    width: 300px;
    margin: auto;
}

I've created a jsFiddle: http://jsfiddle.net/frP2Z/ 我创建了一个jsFiddle: http : //jsfiddle.net/frP2Z/

Here you go: 干得好:

.wizard-box {
    background-color: green;
    height: 300px;
    width: 300px;
    position: absolute;
    left: 50%;
    margin-left: -150px;
    top: 50%;
    margin-top: -150px;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM