代码之家  ›  专栏  ›  技术社区  ›  user2907910

如何阻止文本在表格中垂直居中?

  •  1
  • user2907910  · 技术社区  · 12 年前

    以下是制作该表的html代码:

    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <div class="profile">
            <img src="http://www.teleread.com/wpcontent/uploads/2009/05/image18.png" />
          </div>
        </td>
        <td>Hello</td>
      </tr>
    </table>
    

    这是css:

    .profile img {
        width: 120px;
        height: 125px;
        float: left;
        margin-right: 4px;
        margin-top: 4px;
        margin-bottom: 4px;
        border: 1px #cc1212 solid;
        clear: both;
    }
    

    以下是jsfiddle上正在运行的代码:

    http://jsfiddle.net/Yeqnn/
    

    问题:单词“Hello”在右栏垂直居中

    我该如何解决这个问题?顺便说一句,图像必须在表格中并向左浮动才能使用我当前的主题。。。有什么想法,如果有,请给出答案。

    1 回复  |  直到 12 年前
        1
  •  4
  •   Mr. Alien Redu    12 年前

    简单地说 vertical-align: top; 在您的 <td> 元素。

    Demo