简体   繁体   English

CSS背景的属性值无效

[英]CSS background has invalid property value

I put the below CSS rules in database that are valid in Google Chrome: 我将以下CSS规则放入了在Google Chrome中有效的数据库中:

background: url(/lib/editor/frames/6.1.png) center -7px / 19mm 12mm no-repeat, url(/lib/editor/frames/6.2.png) center 0px / 500mm 1.4mm no-repeat, linear-gradient(to right, rgb(255, 255, 255) 0%, rgb(211, 233, 203) 50%, rgb(255, 255, 255) 100%) center 5px / 500mm 3.7mm no-repeat;
background-color: white;

When I try to add this rules to a div with JQuery, this rule merged as single rule and get invalid value 当我尝试使用JQuery将此规则添加到div时,此规则作为单个规则合并并获得无效值

background: url(/lib/editor/frames/6.1.png) center -7px / 19mm 12mm no-repeat white, url(/lib/editor/frames/6.2.png) center 0px / 500mm 1.4mm no-repeat white, linear-gradient(to right, rgb(255, 255, 255) 0%, rgb(211, 233, 203) 50%, rgb(255, 255, 255) 100%) center 5px / 500mm 3.7mm no-repeat;

How do I know why it is invalid? 我怎么知道为什么它无效?

If you've identified this as a bug this is a bug with a recent version of JQuery, you should report it to the JQuery GitHub issues page; 如果您已将其识别为错误,则这是JQuery的最新版本的错误,则应将其报告给JQuery GitHub问题页面; Not here. 不在这里。

A workaround would be to simply set the the style attribute manually. 一种解决方法是简单地手动设置样式属性。

$('.whatever').attr('style', 'background: url(/lib/editor/frames/6.1.png) center -7px / 19mm 12mm no-repeat, url(/lib/editor/frames/6.2.png) center 0px / 500mm 1.4mm no-repeat, linear-gradient(to right, rgb(255, 255, 255) 0%, rgb(211, 233, 203) 50%, rgb(255, 255, 255) 100%) center 5px / 500mm 3.7mm no-repeat; background-color: white;');

采用

background-image:url('url')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM