扫码关注官方订阅号
鼠标滑过SVG元素时SVG随机伸缩,后恢复原状(各100ms)
//SVG组 Sorry, your browser does not support inline SVG.
这段代码在本地实现得很好,但搬到服务器上就无法绑定,元素的event listener也为空,求解?
小伙看你根骨奇佳,潜力无限,来学PHP伐。
jquery引入了吗
<style> p{ transform: rotate(180deg);//旋转外层p 180°使SVG伸缩方向上下颠倒 transform-origin: 50% 50%; display: inline-block; } g.rect_group rect{ transition: all 0.1s ease;//定义SVG变换时间 } </style> <body> <script src="http://cdn.bootcss.com/jquery/1.12.3/jquery.js"></script> <p> <svg height="300" width="300"> <g class="rect_group" fill="#B9D6E8">//SVG组 <rect height="100" width="20"/> <rect x="25" height="100" width="20"/> <rect x="50" height="100" width="20"/> <rect x="75" height="100" width="20"/> <rect x="100" height="100" width="20"/> </g> Sorry, your browser does not support inline SVG. </svg> <p> <script type="text/javascript"> $(document).ready(function(){ var randomHeight=function($ele){ $ele.data("this_height",$ele.attr("height"));//写入原高度到元素的.data对象 $ele.attr("height",Math.floor((Math.random()+0.5)*parseInt($ele.data("this_height"))));//随机伸长/缩短 setTimeout(function(){ $ele.attr("height",$ele.data("this_height")); },100);//100ms后恢复原状 } $(".rect_group rect").on("mouseover",function(){//注册时间 randomHeight($(this)); }); }) </script> </body>
在本地执行有效果你说的在你服务器上没效果我们也看不到啊
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
jquery引入了吗
在本地执行有效果
你说的在你服务器上没效果我们也看不到啊