html - 垂直对齐属性不适用于谷歌浏览器

标签 html

<html>
    <head>
        <style>
            table,td {border:1px solid black ;}
            table {width : 80% ;height:80%;}
            .top {vertical-align:top};
            .center {vertical-align: middle};
            .bottom {vertical-align: bottom};
        </style>
    </head>
    <body>
        <table>
            <tbody>
                <tr><td class = "top">1</td><td class = "top" "left">2</td><td class = "top" "left">3</td></tr>
                <tr><td class = "center" >4</td><td class = "center">5</td><td class = "center">6</td></tr>
                <tr><td class = "bottom">7</td><td class = "bottom">8</td><td class = "bottom">9</td></tr>
            </tbody>
        </table>
    </body>
</html>

第 8 行,即 .bottom {vertical-align: bottom}; 在 Internet Explorer 8 中运行良好,但在 google chrome 上不起作用,即使我有最新版本。

最佳答案

我认为你有一个简单的语法问题,分号应该在右括号内。

请参阅下面的代码。

此外,将 height: 100% 添加到 bodyhtml 以设置表格单元格高度的引用。

注意:正如其中一条评论所述,您没有为 left 定义 CSS 样式,因此不清楚您的意图。 left 本身不是一个有效的属性。

body,
html {
  height: 100%;
}
table,
td {
  border: 1px solid black;
}
table {
  width: 80%;
  height: 80%;
}
.top {
  vertical-align: top;
}
.center {
  vertical-align: middle;
}
.bottom {
  vertical-align: bottom;
}
<table>
  <tbody>
    <tr>
      <td class="top">1</td>
      <td class="top">2</td>
      <td class="top">3</td>
    </tr>
    <tr>
      <td class="center">4</td>
      <td class="center">5</td>
      <td class="center">6</td>
    </tr>
    <tr>
      <td class="bottom">7</td>
      <td class="bottom">8</td>
      <td class="bottom">9</td>
    </tr>
  </tbody>
</table>

关于html - 垂直对齐属性不适用于谷歌浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38042439/

相关文章:

css - Bootstrap - 在缩小屏幕尺寸的同时对齐标签名称和文本框

html - 将文本/元素定位在 HTML 文档的右侧

javascript - 如何判断浏览器是否支持https资源

javascript - 在客户端裁剪图像

javascript - 如何在 div 中获得粗斜体样式

android - 在 cordova/phonegap 应用程序中设置横向 View 的问题

javascript - Cakephp 2.X 具有内联按钮

php - 我应该将 AJAX 逻辑添加到我的 PHP 类/脚本中吗?

javascript - 如何匹配正则表达式中 < & > 之间的任何内容?

javascript - 忽略父元素溢出