0

我正在尝试position改变

<div class="BannerRedesign" id="Banner" style="position: fixed ! important; height: 36px ! important; width: 100% ! important;">
    <div class="BannerCenterContainer" id="NavigationRedesignBannerContainer">

(roblox 横幅元素,试图使其不浮动)relative使用 Greasemonkey,启用所有权限。但是,每次在文档加载结束时,它都会恢复为浮动状态。

我什至尝试附加bannercentercontainer到一个不同的元素,但我不知道我是否做对了......你能帮我把它改成相对位置吗?

我试过了:

$('#Banner').css('position', 'relative !important')

if ($('#Banner').css('position') == 'fixed') {
$('#Banner').css('position', 'relative')
}

,但是一旦页面完成加载,它就会变回来。

4

1 回答 1

1

该横幅可能设置在静态 HTML 中,并由 AJAX 定期重置。

解决它的一种方法是使用waitForKeyElements() 实用程序

这是一个完整的脚本,可以处理问题中给出的代码:

// ==UserScript==
// @name     _Unfix annoying banner
// @include  http://YOUR_SERVER.COM/YOUR_PATH/*
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require  https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant    GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a design change
    introduced in GM 1.0.   It restores the sandbox.
*/

waitForKeyElements ("#Banner", unFixThePositioning);

function unFixThePositioning (jNode) {
    jNode.css ('position', 'relative');

    //-- Or, for a little extra "Oomph":
    jNode[0].style.setProperty ("position", "relative", "important");

    return true;    //-- Check repeatedly.
}
于 2013-01-31T05:10:45.070 回答