【问题标题】:centering text in an responsive div在响应式 div 中居中文本
【发布时间】:2014-06-25 10:38:50
【问题描述】:

我试图在响应式 div 中垂直居中一些文本。我无法弄清楚。如果我能得到一些帮助,我将不胜感激。

http://jsfiddle.net/X923f/1/

谢谢。

<style>    
.thumb {
    float: left;
    margin: 0px;
    padding: 0px;
    position:absolute;
    height:100%; 
    width:100%; 


}

.thumb img {
    width: 100%;
    padding: 0;
}
.thumb > div {
    background-color: rgba(0,0,0,0.1);
    opacity: 0;
    position: absolute;
    top:0;
    bottom:0;
    left:0;
    right:0;

}
.thumb:hover > div {
    display: block;
    opacity: 1.0;

}
.thumb > div div {
}

#text {
 vertical-align: middle;
  position: relative;
  z-index: 2;
  display: inline-block;
}


</style>

【问题讨论】:

标签: alignment center


【解决方案1】:

这通常是我们在响应式 div 中垂直居中某些文本的方式:

.container {
    min-height: 10em;
    display: table-cell;
    vertical-align: middle 
}

这是你想要垂直居中的 DIV &lt;div class="container"&gt;

【讨论】:

    猜你喜欢
    • 2017-06-02
    • 2014-11-21
    • 2014-10-16
    • 2018-05-03
    • 1970-01-01
    • 1970-01-01
    • 2015-10-22
    • 2023-04-10
    • 1970-01-01
    相关资源
    最近更新 更多