且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用于图像或DIV翻转的纯Javascript

更新时间:2023-11-09 17:56:22

javascript之前你的html代码。



和这个链接是你问我下面的答案评论:
https://jsfiddle.net/ws7054r2/



  #card {display:block;宽度:50px; height:50px;填充:25px;背景颜色:黑色;白颜色; font-family:'Arial',sans-serif;} $ c> $ p> &LT;脚本&GT; var k = 0;函数flip(){var j = document.getElementById(card); k + = 180; j.style.transform =rotatey(+ k +deg); j.style.transitionDuration =0.5s}< / script>< div id =cardonmouseover =flip()>示例文本< / div>  


As i need to code html in my software so i need only pure javascript for fliping.

Please no css animation or Jquery animation, only pure javascript.

need similar to : http://pingmin-tech.com/flipcardjs

found one solution here : DEMO

but it will be better if i get similar to http://pingmin-tech.com/flipcardjs

javascript before your html code.

and this link is the answer your asked me below comments: https://jsfiddle.net/ws7054r2/

#card {
  display: block;
  width: 50px;
  height: 50px;
  padding: 25px;
  background-color: black;
  color: white;
  font-family: 'Arial', sans-serif;
}

<script>
  var k = 0;

  function flip() {
    var j = document.getElementById("card");
    k += 180;
    j.style.transform = "rotatey(" + k + "deg)";
    j.style.transitionDuration = "0.5s"
  }
</script>
<div id="card" onmouseover="flip()">sample text</div>