在Firefox中的位置相对

Joh*_*Smt 0 css firefox css-position

可能重复:
Firefox是否支持位置:相对于表元素?

下面是一个示例:全宽菜单作为表格,ul-s作为下拉菜单. http://cssdesk.com/dW7WS

在ie和opera中工作正常,但在firefox下拉uls拉伸在整个屏幕上!

有帮助吗?

thi*_*dot 7

position: relative不适用于表格单元格(<td>display: table-cell).

来自规范:http://www.w3.org/TR/CSS21/visuren.html#propdef-position

'position:relative'对table-row-group,table-header-group,table-footer-group,table-row,table-column-group,table-column,table-cell和table-caption元素的影响未定义.

所以,Firefox没有做错任何事,尽管我希望它能复制其他浏览器并使其发挥作用.

要使其工作,您需要div在每个内部添加一个包装器td(并调整您的CSS选择器):

<table id="mainmenu">
    <tr>
        <td>
            <div style="position: relative;">
                <a href="#">..</a>
                <ul>
                    ..
                </ul>
            </div>
        </td>

        ..
    </tr>
</table>
Run Code Online (Sandbox Code Playgroud)