html - 垂直对齐表格单元格中的多个对象

标签 html css

这是 jsFiddle . 如何在不使用绝对值(即 px)的情况下,将 imgdiv 垂直居中放置在 td 中?

纯 CSS 解决方案值得赞赏。谢谢。

最佳答案

像这样?

http://jsfiddle.net/Mgwzx/10/

<div style="width:100%; height:60px; position:relative; overflow:visible;">
    <table style="width:400px; table-layout:fixed" cellspacing="0" cellpadding="0">
        <tr>
            <td style="vertical-align: middle; width:200px;">
                <img align="left" src="http://upload.wikimedia.org/wikipedia/donate/c/c0/Information-icon.png" style="float:left;margin-top:50px;" />
                <div style="text-align:center; float:left; width:150px;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat</div>
            </td>
        </tr>
    </table>
</div>

关于html - 垂直对齐表格单元格中的多个对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15575637/

相关文章:

javascript - 如何将文本打印到文本区域?

javascript - 寻找一种在 HTML 中卡住表格行和列的方法

html - 网站目录不起作用?

css - 额外的白线/像素

html - 如何旋转立方体并使用 css html 扩展其边?

Javascript 在事件时用函数替换 div 的内容

css - 尽管样式为 ="clear:both",但 div 重叠页脚?

JavaScript 代码无法正常工作

javascript - 根据内容设置 iFrame 高度

html - CSS Grid如何选择行添加悬停效果?