zoukankan      html  css  js  c++  java
  • 火狐浏览器对svg支持的一点不足

    项目中要用svg实现一个如下图所示的风机扇叶转动效果

    当用chrome浏览器打开,动画显示正常。用火狐浏览器打开扇叶静止不动,代码如下:

    <svg xmlns:cge="http://iec.ch/TC57/2005/SVG-schema#" width="100%" moveX="0" moveY="0" fill="none" zoomScale="-100%" xmlns:xlink="http://www.w3.org/1999/xlink" onload="window.parent.init(evt, 1)" xmlns="http://www.w3.org/2000/svg" height="100%" visibility="visible" xml:space="preserve" name="D0C2D4B0C7F8BFD5B5F7CFB5CDB3D7DCC0C0475241.xml" viewBox="0 0 1691 959" >
        <defs>
    		<!--风机-->
    		<g id="windleaf">
    			<polygon stroke-linecap="round" stroke-dasharray="none" x="88" y="165" fill="#999999" points="88,165 82,148 68,128 59,119 45,112 31,110 18,108 10,107 3,98 6,84 9,76 18,65 25,57 38,43 64,22 82,14 103,8 122,4 137,2 162,1 176,2 194,8 208,13 215,20 228,35 234,46 240,61 239,81 239,93 234,108 224,124 217,132 205,142 189,156 165,176 152,190 142,194 122,201 109,202 101,198 93,182 " stroke="#000000" fill-opacity="1" opacity="1" stroke-width="1" />
    		</g>	
    		<g id="windgeneratorleaves-on">
    			<use xlink:href="#windleaf" transform="translate(0,-100)"/>
    			<use xlink:href="#windleaf" transform="translate(0,-100) rotate(-120 109,202 )"/>
    			<use xlink:href="#windleaf" transform="translate(0,-100) rotate(120 109,202 )"/>
    			<circle transform="translate(0,-100)" cx="109" cy="202" r="32" stroke="#FFFFFF" stroke-width="1" fill="#A0A0A0"/>		
    			<animateTransform attributeName="transform" begin="0s" dur="1s" type="rotate" from="0 109 102" to="360 109 102" repeatCount="indefinite"/>
    		</g>
        </defs>
        <g esclass="fanType" transform="translate(83,86) scale(0.07)" id="id156401fan">
    		<use xlink:href="#windgeneratorleaves-off" x="0" y="0"></use>
        </g>
        
        <!-- TODO-->
    </svg>
    

    通过调试发现,在< defs>中预定义的风机转动动画,通过元素引用的时候,chrome浏览器显示正常,火狐浏览器显示不正常。当把animateTransform 放到use元素外时能正常显示。

    正常显示的引用

    <defs>
    		<!--风机-->
    		<g id="windleaf">
    			<polygon stroke-linecap="round" stroke-dasharray="none" x="88" y="165" fill="#999999" points="88,165 82,148 68,128 59,119 45,112 31,110 18,108 10,107 3,98 6,84 9,76 18,65 25,57 38,43 64,22 82,14 103,8 122,4 137,2 162,1 176,2 194,8 208,13 215,20 228,35 234,46 240,61 239,81 239,93 234,108 224,124 217,132 205,142 189,156 165,176 152,190 142,194 122,201 109,202 101,198 93,182 " stroke="#000000" fill-opacity="1" opacity="1" stroke-width="1" />
    		</g>	
    		<g id="windgeneratorleaves-on">
    			<use xlink:href="#windleaf" transform="translate(0,-100)"/>
    			<use xlink:href="#windleaf" transform="translate(0,-100) rotate(-120 109,202 )"/>
    			<use xlink:href="#windleaf" transform="translate(0,-100) rotate(120 109,202 )"/>
    			<circle transform="translate(0,-100)" cx="109" cy="202" r="32" stroke="#FFFFFF" stroke-width="1" fill="#A0A0A0"/>		
    		</g>
    </defs>
     <g esclass="fanType" transform="translate(83,86) scale(0.07)" id="id156401fan">
    		<use xlink:href="#windgeneratorleaves-off" x="0" y="0"></use>
                    <!-- animateTransform 放到了这里-->
                    <animateTransform attributeName="transform" begin="0s" dur="1s" type="rotate" from="0 109 102" to="360 109 102" repeatCount="indefinite"/>
    </g>
    

    您的资助是我最大的动力!
    金额随意,欢迎来赏!

  • 相关阅读:
    osip状态机分析
    配置tomcat 加载指定的jar
    oracle创建用户并指定表空间
    CentOS7通过rsync+crontab实现两台服务器文件同步
    CentOS7配置MySQL5.7主备
    CentOS7本地安装MySQL5.7
    设置mysql 事务锁超时时间 innodb_lock_wait_timeout
    获取指定年月的第一天与最后一天
    Nginx 反向代理504 Gateway Time-out
    ubuntu下安装配置apache2与php
  • 原文地址:https://www.cnblogs.com/Corphish/p/7122455.html
Copyright © 2011-2022 走看看