css - 在两个相邻的 div block 中对齐具有不同字体大小的文本

标签 css html fonts font-size

我有以下代码:http://jsfiddle.net/eNzjZ/81/

<style>
.bigLabel {    
   font-size: 128px;    
}

.smallLabel {    
   font-size: 64px;    
}

</style>
<div>
    <div style="position: absolute; left: 0px; top: 0px; width: 102px; height: 170px; z-index: 216614; overflow: visible; cursor: default;">
        <div>
            <table cellspacing="0" cellpadding="0" width="102px" height="170px">
                <tbody>
                    <tr>
                        <td class="bigLabel" style="padding:0px;background-color:yellow;" align="bottom" valign="bottom">T32</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div style="position: absolute; left: 210px; top: 0px; width: 400px; height: 170px; z-index: 216632; overflow: visible; cursor: default;">
        <div>
            <table cellspacing="0" cellpadding="0" width="400px" height="170px">
                <tbody>
                    <tr>
                        <td class="smallLabel" style="padding:0px;background-color:orange;" align="bottom" valign="bottom">T0.00 0.00</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>

问题是两个 block 中文本的底部没有对齐。 大字体比小字体高。

有没有可能,只改变css或style属性,让这两段文字对齐到底部?

最佳答案

您可以为字体较大的文本添加行高。

<td class="bigLabel" style="padding:0px;background-color:yellow; line-height: 115px;" align="bottom" valign="bottom">T32</td>

Jsfiddle

关于css - 在两个相邻的 div block 中对齐具有不同字体大小的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31159376/

相关文章:

javascript - IE 7/8 的 jQuery 悬停闪烁错误

javascript - 为什么我的 DataTables 插件根本不起作用?

HTML5 Canvas 图层难题(z-index)

java - JEdi​​torPane 中呈现数学符号的问题

c# - 如何更改 Silverlight 使用的默认字体?

html - 如何在 CSS 中垂直和水平居中具有不同字体大小的文本

CSS:如何让这个 Div 保持在 float 的右侧?

javascript - 垂直和水平居中 HTML5 Javascript

html - CSS3 输入选择器

javascript - 用于将图像显示到 Canvas 的简单 Websocket