gpt4 book ai didi

jquery - 使用 jQuery 更新多个后台 CSS 定义

转载 作者:行者123 更新时间:2023-11-28 11:47:54 25 4
gpt4 key购买 nike

谁能想出一种方法来一次更新多个背景定义?

我已经用一些代码做到了这一点,但我想为一个元素更新许多不同风格的渐变背景。

$('ul#tabs li').on('mousemove',function(e){ 
var x= Math.round(((e.pageX - this.offsetLeft)*100)/$(this).width());
x= x-10;
$(this).find(".highLight").css({
'background': '-webkit-linear-gradient(left,
rgba(255,255,255,0) 0%,
rgba(255,255,255,0.5)'+x+'%,
rgba(255,255,255,0) 100%)'
});});

如有任何想法,我们将不胜感激。

最佳答案

你可以使用 http://lea.verou.me/prefixfree/

A script that lets you use only unprefixed CSS properties everywhere. It works behind the scenes, adding the current browser’s prefix to any CSS code, only when it’s needed.

..

Lets jQuery’s .css() method to get and set unprefixed properties (requires plugin)

或者,您可以为每个浏览器的渐变语法调用 .css():

var $highLight = $(this).find(".highLight");
$highLight.css('background', '-webkit-linear-gradient( .. )');
$highLight.css('background', '-moz-linear-gradient( .. )');
//include others such as opera, old webkit, microsoft
$highLight.css('background', 'linear-gradient( .. )');

只会应用每个浏览器支持的渐变语法。

关于jquery - 使用 jQuery 更新多个后台 CSS 定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9381311/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com