<!doctype html> <html> <head> <style> @keyframes blink {   0% {     background-position: 0;   }   100% {     background-position: -1020px;   } } .likeNum{     padding: 1px;       font-size: 20px;      } .like-container{     display: flex;     align-items: center; } .like-container > *{      display: inline-block; } a.like{   pointer: cursor; } .like > span{   display: inline-block;   width: 64px;   height: 64px;   background: url(http://oncn5i9yi.bkt.clouddn.com/downloadxxx.png) left no-repeat;   background-position: 0  0; } .blink{   animation: blink steps(17) 0.5s 1 both; } </style> </head> <body>  <div class="like-container">  <a class="like"><span></span></a>  <span class="likeNum">赞</span>  </div> <script> </script> <script>   document.addEventListener("DOMContentLoaded", function(e) {    let node = document.querySelector("a.like");    node && node.addEventListener("click", (event) => {           event.stopPropagation();           event.preventDefault();           let target = event.target.tagName.toUpperCase() == "SPAN" ? event.target :   event.target.parentNode;           target.classList.toggle("blink");              });   }); </script> </body> </html>
点赞 2

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务