[英]Insert css animation internet explorer javascript
我想在Internet Explorer中使用javascript插入動畫。 似乎不起作用。 用chrome,ff沒問題。 請查看以下鏈接:
var style = document.documentElement.appendChild(document.createElement("style")),
rule="@keyframes test{ 0%{opacity:1;} 50%{opacity:0;} 100%{opacity:1;}} ";
style.sheet.insertRule(rule);
$(".mojo")[0].style["animation"] = " test 3s ease-out both infinite";
動畫是否正在與IE10一起使用。 在運行時插入動畫似乎不起作用。
insertRule
方法需要兩個值: 第一個是新規則字符串,第二個是您希望在其他規則中添加它的索引。
索引為0
會將規則推到頂部,而索引等於規則總數的索引會將其推到規則的底部。
// Add a new rule to the bottom of the first stylesheet
sheet.insertRule( rule, sheet.rules.length );
將此索引添加到演示中可解決此問題: http : //jsfiddle.net/273e2/19/show/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.