如何在css中对齐背景图像的文本中间

如何在css中对齐背景图像的文本中间,css,Css,我想在css中对齐背景图像中间的内容。 我是这样使用代码的 section.center_content { background: url(../images/center_bg.jpg) center no-repeat; border-bottom: 1px solid #e5e5e5; font-family:Arial, Helvetica, sans-serif; margin-bottom: 40px; background-si

我想在css中对齐背景图像中间的内容。 我是这样使用代码的

 section.center_content {
     background: url(../images/center_bg.jpg) center no-repeat;
     border-bottom: 1px solid #e5e5e5;
     font-family:Arial, Helvetica, sans-serif;
     margin-bottom: 40px;
     background-size:100%;
     height:190px;
 }
 .ticker-content {
     vertical-align:middle;
 }
 .ticker-content h1 {
     color:#FFFFFF;
     font-size:45px;
 }
 .ticker-content h2 {
     color:#BFBFBF;
     font-size:35px;
 }
 .ticker-content p {
     color:#BFBFBF;
     font-size:20px;
 }

请给出一个解决方案。提前非常感谢

将以下属性添加到您的
部分。中心内容

section.center_content {
    background:blue;
    border-bottom: 1px solid #e5e5e5;
    font-family:Arial, Helvetica, sans-serif;
    margin-bottom: 40px;
    height:190px;
    width:100px;

    /*Vertically center*/
    display:table-cell;    /*This makes the div behave like a table cell*/
    vertical-align:middle; /*This property is only available on table cells*/

    /*Horizontal center*/
    text-align:center;     /*This you know centers text horizontally*/
}

.ticker-content{
    /*Remove vertical-align:middle; from here*/
}


请注意,并将其保留以备将来参考。

css属性垂直对齐适用于内联元素和表格单元格元素


将一个显示:表单元格添加到元素中,以便在中间对齐。

,您总是可以使用与容器高度相等的行高度属性。

如果您能够,请为这些动作提供解释。谢谢@辍学是的,我正在添加它。请两分钟。@Dropout很高兴能为您提供帮助:)整体移动网站的左侧,而不是全视图。@user3265980如果您可以共享HTML标记,那就太好了。如果添加显示:表格单元格,则移动到页面的左侧。实际上看不到