html - 表格单元格在 Firefox、IE 中未对齐

标签 html css browser html-table

我正在尝试创建一个表,其第一列是固定的。我已经以某种方式做到了,但我无法在所有浏览器中获得相同的结果。结果仅在 Chrome 上是正确的。这是我在 Firefox/IE 8 上得到的结果:

enter image description here

在 Chrome 上:

enter image description here

这是我的 HTML 代码:

<div id="riassuntoOreTecnico">

<table id="riassuntoOreTecnicoTable" >
    <tr>
        <th>Technician Name</th>
        <td style="padding-left:165px"></td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
    </tr>   
    <tr>
        <th>Table Cell</th>
        <td style="padding-left:165px"></td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>
        <td>Table Cell</td>

        <td>Table Cell</td>
    </tr>
</table>

</div>

还有 CSS:

#riassuntoOreTecnico {
    width: 94%;
    float: left;
    margin: 30px 35px;
    overflow-x: scroll;
    overflow-y: visible;
}

#riassuntoOreTecnicoTable {
/*  border-collapse: separate;*/
    border: 1px solid #ddd;
    float: left;
}

#riassuntoOreTecnicoTable th {
    background: #d5d5d5;
    font-weight: bold;
    padding: 5px 8px;
    position: absolute;
    top:auto;
    width:158px;
}

#riassuntoOreTecnicoTable td {
    border: 1px solid #d5d5d5;
    padding: 5px 8px;
}

任何人都可以建议我的代码这里有什么问题,以便我也可以在 firefox/IE8 上获得相同的结果吗?

最佳答案

我在表格 CSS 中添加了 white-space:normal 并为我修复了它。

这是更新后的代码:

#riassuntoOreTecnicoTable {
/*  border-collapse: separate;*/
    border: 1px solid #ddd;
    float: left;
    white-space:normal
}

谢谢大家

关于html - 表格单元格在 Firefox、IE 中未对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24607937/

相关文章:

html - css3 动画在 chrome 中不起作用

javascript - insertAdjacementHTML 不是 <anonymous> 的函数

php - 双选择框无法正确发布

html - 书签 :~:text= specifications

javascript - 我们可以下载 .js 文件和图片 P2P 吗?

java - 如何在 Web 浏览器内的 Javascript 代码和 Java 代码之间传递信息

javascript - 在 Chrome 中分析 Javascript 时,我怎么知道我已经处理了内存泄漏?

html - 使用CSS设置背景图像而不拉伸(stretch)图像

javascript - 如何自动关闭 Bootstrap 4 下拉菜单中的子菜单

html - 为什么我不能以边距 : 0 auto? 为中心