gpt4 book ai didi

css - Firefox 中的 Div 位置问题

转载 作者:搜寻专家 更新时间:2023-10-31 08:19:34 26 4
gpt4 key购买 nike

我正在编写这段代码,这段代码在 Chrome 中运行良好,但在 Firefox 中运行良好

这是代码

<html lang="en-US">
<body><table style="width: 100%;">
<tbody><tr>
<td style="position: relative; width: 50%; height: 500px; vertical-align: top; overflow: hidden;">
<div style="position: absolute; background-color: blue; height: 100%; width: 100%;"></div></td>
<td style="position: relative; width: 50%; height: 500px;"></td>
</tr>
</tbody></table>
</body>
</html>

If you want to see here is JSFiddle for code in working

请解释为什么 Firefox 中的 div 覆盖了整个屏幕宽度,它应该只覆盖 50% 的宽度,如 Chrome 显示的那样。

最佳答案

可能是因为从 2.1 Specification 开始CSS 未定义表格单元格元素的相对定位:

The box's position is calculated according to the normal flow (this is called the position in normal flow). Then the box is offset relative to its normal position. When a box B is relatively positioned, the position of the following box is calculated as though B were not offset. The effect of 'position:relative' on table-row-group, table-header-group, table-footer-group, table-row, table-column-group, table-column, table-cell, and table-caption elements is undefined.

Positioned Layout Module 开始,这不是真的(他们明确定义了行为)但尚未被供应商采用。

关于css - Firefox 中的 Div 位置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17031876/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com