zoukankan      html  css  js  c++  java
  • js给图层添加动态样式

    需求:需要在视窗内随意点击对应位置,图层从上到下匀速运动到指定位置

    html

    <img id="moveDot" class="moveDot" src="images/moveDot.png">
    

    js

    //地图插点动态效果
    //横坐标
    var x=120;
    //纵坐标
    var y=200;
    var style = document.styleSheets[0];
    style.insertRule('.moveDot {30px;height:auto;position:absolute;left:'+x +'px;top:'+y +'px;z-index:999999;animation:mymove 500ms;-webkit-animation:mymove 500ms;animation-timing-function:linear;}', 0);
    style.insertRule('@keyframes mymove{from{ top:0; }to{top:'+y +'px;}}',0);
    style.insertRule('@-webkit-keyframes mymove{from{ top:0; }to{top:'+y +'px;}}',0);
    

      

  • 相关阅读:
    第五章4
    第五章3
    第五章2
    第五章1
    第四章14
    第四章13
    第四章12
    第四章11
    第五章例5-6
    第五章例5-4
  • 原文地址:https://www.cnblogs.com/joesmile/p/10312664.html
Copyright © 2011-2022 走看看