【问题标题】:Gradient Filter on jQuery css() MethodjQuery css() 方法上的渐变过滤器
【发布时间】:2013-05-17 19:17:57
【问题描述】:

我尝试更改页面的某些样式,我希望使用jQuery - css() methodon userscript 更改样式。

我尝试了 jsfiddle,我的浏览器使用 Tampermonkey

某些属性样式已更改,但gradient filter 未更改。这是页面上的样式:

#site-header .meta-header {
    width: 100%;
    min-width: 960px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 30px;
    background-color: #1484ce;
   filter: progid:DXImageTransform.Microsoft.gradient(gradientType=0, startColorstr='#FF1484CE', endColorstr='#FF1274B5');
        background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #1484ce), color-stop(100%, #1274b5));
    background-image: -webkit-linear-gradient(top, #1484ce 0%,#1274b5 100%);
    background-image: -moz-linear-gradient(top, #1484ce 0%,#1274b5 100%);
    background-image: -o-linear-gradient(top, #1484ce 0%,#1274b5 100%);
    background-image: linear-gradient(top, #1484ce 0%,#1274b5 100%);   
    -webkit-box-shadow: 0 2px 0 #0e5a8c;
    box-shadow: 0 2px 0 #0e5a8c;
    border-bottom: solid 1px rgba(255,255,255,0.1);
    font-size: 13px;
    }

这是我的用户脚本:

// ==UserScript==
// @name       Change Style
// @namespace  http://use.i.E.your.homepage/
// @include    http://fiddle.jshell.net/tAKHd/show/light/
// @version    0.1
// @description  enter something useful
// @require        http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.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.
*/


$("body").css({
    "background": "none",
    "background-color": "#2f2f2f"
});

$("#site-header .meta-header").css({
    "background-color": "#2c2c2c",

    /*start - This is style not showing*/

    "filter" : "progid:DXImageTransform.Microsoft.gradient(gradientType=0, startColorstr='#333333', endColorstr='#222222')",
    "background-image": "-webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #333), color-stop(100%, #222))",
    "background-image": "-webkit-linear-gradient(top, #333 0%,#222 100%)",
    "background-image": "-moz-linear-gradient(top, #333 0%,#222 100%)",
    "background-image": "-o-linear-gradient(top, #333 0%,#222 100%)",
    "background-image": "linear-gradient(top, #333 0%,#222 100%)",

    /* end */

    "-webkit-box-shadow": "0 2px 0 rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1)",
    "box-shadow": "0 2px 0 rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1)",
    "border-bottom": "solid 1px rgba(255,255,255,0.1)"
});

我该如何解决?

【问题讨论】:

    标签: jquery css tampermonkey


    【解决方案1】:

    好的,我的问题解决了

    解决办法:

    var meta = $("#site-header .meta-header")
    meta.css("background-image", "-webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #333), color-stop(100%, #222))");
    meta.css("background-image", "-webkit-linear-gradient(top, #333 0%,#222 100%)");
    meta.css("background-image", "-moz-linear-gradient(top, #333 0%,#222 100%)");
    meta.css("background-image", "-o-linear-gradient(top, #333 0%,#222 100%)");
    meta.css("background-image", "linear-gradient(top, #333 0%,#222 100%)");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-22
      相关资源
      最近更新 更多