對於遇到問題,這個人,我有一個解決辦法。
我有一個完整的SVG ID和CSS動畫,都適用於所有其他主流瀏覽器。
我把我的SVG插入到HTML中,所以我可以訪問CSS動畫的每個項目。
對於這個工作,你必須有你的SVG與位置:
absolute; top: 0px; left: 0px,
...一個容器內.svgcontent
(或任何你想將它命名)
腳本:
var IE = (navigator.userAgent.indexOf("Edge") > -1 || navigator.userAgent.indexOf("Trident/7.0") > -1) ? true : false;
objs = [ '#file1', '#file2','#file3','#file4','#file5','#file6','#file7','#file8','#file9','#file10','#file11', '#bottom' ];
if (IE){
objs.forEach(function (item) {
item = $(item);
id = item.attr('id');
svgcontent = item.closest('.svgcontent')
svg = item.closest('svg');
svgattrs = ' width='+svg.attr('width')+' height='+svg.attr('height')+' '
html = '<svg id="'+id+'" '+svgattrs+'>'+item.html()+'</svg>';
item.remove();
$(svgcontent).prepend(html);
});
}
這將獲取objs
數組中的所有元素,並將它們作爲完整的SVG插入到t他第一個(你可以改變prepend
到append
來改變這種行爲)。
而SVG將與對象具有相同的id,因此CSS動畫將應用於完整的SVG,而不是SVG對象。
就是這樣!
哪個版本的IE? –
在瀏覽器11上進行Im測試 – canute
您必須爲您在IE中看到的顏色定義筆觸屬性。但我認爲你將不得不使用單獨的CSS動畫屬性來代替簡單的'animation' CSS屬性。你可以在這裏看到:http://jsfiddle.net/z8w4vuau/50/ ..我如何在'.loader-path''' circle'元素上添加'stroke'屬性並增加了'stroke-dasharray'所以你可以看到它正在旋轉,但是IE並沒有爲你的'stroke-dasharray'和'stroke-dashoffset'設置動畫。因此,只需使用長格式的CSS動畫屬性即可。 –