Element的CSS,在页面加载结束时还原? [英] Element's CSS, reverts back at the end of page load?
问题描述
我正在尝试更改
$ b
I am trying to change the position
of
<div class="BannerRedesign" id="Banner" style="position: fixed ! important; height: 36px ! important; width: 100% ! important;">
<div class="BannerCenterContainer" id="NavigationRedesignBannerContainer">
(roblox横幅元素,试图使其不浮动)
到 relative
使用Greasemonkey,启用所有权限。
(roblox banner element, trying to make it not float)
to relative
using Greasemonkey, with all privileges enabled. But, every time, at the end of the loading of the document, it reverts to floating.
我甚至尝试添加 bannercentercontainer
到一个不同的元素,但我不知道如果我做的正确...
你能帮我把这个更改为相对位置吗?
I even tried appending bannercentercontainer
to a different element, but I don't know if I did it right...
can you please help me change this to relative position?
我试过:
$('#Banner').css('position', 'relative !important')
和
if ($('#Banner').css('position') == 'fixed') {
$('#Banner').css('position', 'relative')
}
,但只是在网页加载完成后才更改。
, but it just changed back once the page finished loading.
推荐答案
该横幅可能设置在静态HTML中,并由AJAX定期重置。
That banner is probably set in the static HTML and periodically reset by AJAX.
解决方法是使用 waitForKeyElements()实用程序。
以下是完整脚本,可用于问题中提供的代码:
Here is a complete script that will work on the code given in the question:
// ==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.
}
这篇关于Element的CSS,在页面加载结束时还原?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!