表格行中div中标签的水平和垂直对齐 [英] horizontal and vertical alignment of label in div in table row

查看:108
本文介绍了表格行中div中标签的水平和垂直对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有代码:

<tr>
    <td align="center" style="height: 50px; text-align: center; vertical-align: middle"   >
           <div class="hoverClass ui-widget-content ui-corner-all" style="text-align: center; vertical-align: middle;width:100%;height:100%">
                 <label style="text-align: center; vertical-align: middle" >Streetlight Repair</label>
           </div>
     </td>
</tr>

我希望它是一个包含div且包含标签的单元格。
我希望div占用整个单元格。标签要在div中居中。但是标签位于div的左上方。

I want it to be a cell with a div containing a label. I want the div to take up the whole cell. and the label to be centered within the div. However the label sits at the top left of the div.

推荐答案

如果高度一定是50px,则设置line-height CSS标签的像素为50像素;

If the height is definitely 50px, set the line-height CSS of the label to 50px;

要水平获取标签,请设置margin-left:auto;和margin-right:auto;

To get the label in the middle horizontally, set margin-left:auto; and margin-right:auto;

这篇关于表格行中div中标签的水平和垂直对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆