简体   繁体   English

Firefox在表格单元中的绝对位置

[英]Firefox position absolute in table-cell

Suprisingly enough it's not IE which causes me trouble, but Firefox. 令人惊讶的是,不是IE引起了我的麻烦,而是Firefox。

Fiddle: http://jsfiddle.net/EwUnt/ 小提琴: http//jsfiddle.net/EwUnt/

Point of this table is to highlight row and column of the cell on which cursor is. 该表的重点是突出显示光标所在的单元格的行和列。

The thing is every time im testing it under Firefox it highlights only row itself instead of both, column and row.(works well in IE, Chrome, Safari and Opera) 事情是每次在Firefox下进行即时测试时,它只突出显示行本身,而不突出显示列和行。(在IE,Chrome,Safari和Opera中运行良好)

On JS fiddle it works well, however on blank html or Wordpress it does not. 在JS小提琴上,它运作良好,但是在空白html或Wordpress上却无法。

I'm loading these libraries with it. 我正在加载这些库。

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://codeorigin.jquery.com/ui/1.9.2/jquery-ui.js"></script>

And the script: 和脚本:

    $(document).ready(function () {
function firefoxFix() {

    if ( /firefox/.test( window.navigator.userAgent.toLowerCase() ) ) {

        var tds = document.getElementsByTagName( 'td' );

        for( var index = 0; index < tds.length; index++ ) {
            tds[index].innerHTML = '<div class="ff-fix">' + tds[index].innerHTML + '</div>';                     
        };

        var style = '<style>'
            + 'td { padding: 0 !important; }' 
            + 'td:hover::before, td:hover::after { background-color: transparent !important; }'
            + '</style>';
        document.head.insertAdjacentHTML( 'beforeEnd', style );

    };

};

firefoxFix();
)};

What's wrong with it? 它出什么问题了?

Firefox has a problem with relative/absolute positioning whenever tables or display: table-cell is involved. 每当涉及表或display: table-cell时,Firefox都会存在相对/绝对定位问题display: table-cell涉及display: table-cell This has been reported to the Firefox devs but so far no fix has been implemented. 已经向Firefox开发人员报告了此问题,但到目前为止尚未实现修复。 Bug report 1 - Bug Report 2 错误报告1- 错误报告2

Because of this, the width: 100% on your td:hover::after is seen relative to the body instead of the cell. 因此,您在td:hover::after上看到的width: 100%相对于身体而不是细胞。

You can fix this by setting your td to display: inline-block and specifying a width. 您可以通过将td设置为display: inline-block并指定宽度来解决此问题。

Fix can be seen here: http://jsfiddle.net/EwUnt/27/ 可以在这里查看修复程序: http : //jsfiddle.net/EwUnt/27/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM