为了账号安全,请及时绑定邮箱和手机立即绑定

Uncaught DOMException: Failed to execute 'insertRule' on 'CSSStyleSheet': Cannot access StyleSheet to insertRule

$(()=>{

var outerWidth = 600,

outerHeight = 400,

speed = 3;

var $marquee = $('.marquee');

var $content = $marquee.find('.content');

var $list = $content.find('.list');

var listLength = $list.length;

var contentWidth = outerWidth * listLength;

var style = document.styleSheets[0]

// console.log('style',style);

$marquee.css({

"width":`${outerWidth}px`,

"height":`${outerHeight}px`,

});

$list.css({

"width":`${outerWidth}px`,

"height":`${outerHeight}px`,

});

$content.css({

"width":`${contentWidth}px`,

"height":`${outerHeight}px`,

"animation": `lunbo ${speed*listLength}s linear infinite;`

});

style.insertRule(`@keyframes lunbo{

           100%{

               transform: translateX(-${contentWidth}px);

           }

       }`)

});


正在回答

2 回答

没有加载到样式表,文件有问题吧

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

Uncaught DOMException: Failed to execute 'insertRule' on 'CSSStyleSheet': Cannot access StyleSheet to insertRule

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信