简体   繁体   English

引导程序中的垂直对齐

[英]Vertical Alignment in Bootstrap

Hi I'm having a bit of trouble with getting a piece of text to align vertically in the follow div: 嗨,我在让一段文本在以下div中垂直对齐遇到了一些麻烦:

           <div class = "col-md-12" style = "height:60%;padding:10px;">
              <div style = "background-color: #ffec31;height:100%;">
                 <p>
                    blah
                 </p>
              </div>
           </div>

(the inline styling is just for testing that will be taken out at some point) (内联样式仅用于将在某个时候进行的测试)

I have no idea how to do this and I've tried various things including: 我不知道该怎么做,我已经尝试了各种方法,包括:

position: relative;
top: 50%;
transform: translateY(-50%);

but perhaps I'm doing something wrong. 但是也许我做错了。

Many Thank 多谢

http://jsfiddle.net/zj9v81t7/24/ see the jsfiddle. http://jsfiddle.net/zj9v81t7/24/参见jsfiddle。

.col-md-12{ height: 74px;
    padding: 10px;}
p {
    height: 20px;
    margin-top: -10px;
    position: absolute;
    top: 50%;
}

https://gist.github.com/marioblas/9952094 https://gist.github.com/marioblas/9952094

/* Align vertically a column */
.v-align {
    float: none;
    display: inline-block;
    vertical-align: middle;
}

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

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