简体   繁体   English

使用css垂直对齐文本

[英]Vertical Align of text using css

I am trying to get this: 我试图得到这个:

http://img16.imageshack.us/img16/2198/screenshot20130304at146.png

But after 2 hours I have this: 但是2小时后我就有了这个:

http://imageshack.us/photo/my-images/138/screenshot20130304at152.png

The problem is I have no idea of how align the text on the button without using javascript, only with css. 问题是我不知道如何在不使用javascript的情况下对齐按钮上的文本,仅使用css。 There is anyway to do this without Javascript? 无论如何没有Javascript可以做到这一点? This is my code: 这是我的代码:

<div class='chart_button'>
    <div>Pain Relief</div>
</div>
<div class='chart_button'>
   <div>Pain relief by attack</div>
</div>

and here is the css: 这是css:

.button_set .chart_button{
    display: inline-table;
    height: 50px;
    width: 110px;
    background: url('../img/button-chart.png');
    font-size: 14px;
    font-weight: bold;
    color: #717171;
    text-align: center;
    margin-right: 1px;
    cursor: pointer;
    vertical-align: bottom;
}

Add this CSS: 添加此CSS:

.chart_button>div {
    display:table-cell;
    vertical-align:middle;
}

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

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