首页 > js操作css

js操作css

-webkit-linear-gradient( bottom,rgba(0,0,0,0),rgba(0,0,0,.7));
如何用js操作呢,
dom.style.webkitLinearGradient = '(bottom,rgba(0,0,0,0),rgba(0,0,0,.7))';  不对
dom.style.webkitLineargradient = '(bottom,rgba(0,0,0,0),rgba(0,0,0,.7))';  也不对

linear-gradient是一个颜色值,不是属性,你应该在CSS中这样写比如说background:-webkit-linear-gradient( bottom,rgba(0,0,0,0),rgba(0,0,0,.7));,JS中dom.style.background="-webkit-linear-gradient( bottom,rgba(0,0,0,0),rgba(0,0,0,.7))";


dom.style.background='-webkit-linear-gradient( bottom,rgba(0,0,0,0),rgba(0,0,0,.7))'

这样,你见过css那样写的吗


'-webkit-linear-gradient( bottom,rgba(0,0,0,0),rgba(0,0,0,.7))'这一整个字符串是一个属性值,所以使用dom操作的话应该是这样:

dom.style.属性名 = '-webkit-linear-gradient( bottom,rgba(0,0,0,0),rgba(0,0,0,.7))';
【热门文章】
【热门文章】