js网页点击音乐图片按钮控制音乐播放,转动

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <title>animation</title>
   <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
   <style>
       *{padding:0;margin:0;}
/*定义*/
       @-webkit-keyframes rotatae{
           0%{
               transform:rotate(0deg);
           }
           100%{
               transform:rotate(360deg);
           }
       }
       /*调用*/
       div{
           width:50px;
           height:50px;
           background:blue url(images/1.jpg);
           background-size:100% 100%;
           -webkit-animation-name:rotatae;
           -webkit-animation-duration:2s;
           -webkit-animation-timing-function:linear;
           -webkit-animation-iteration-count:infinite;
           position:fixed;
           right:10px;
           top:10px;
       }
    </style>
</head>
<body>
   <div id="icon"></div>
   <!-- autoplay 自动播放 loop 循环播放 controls 控件 -->
   <audio  id="audio" src="audio.mp3">此浏览器不支持audio</audio>
</body>
   <script src="js/jquery1.7.js"></script>
   <script>
   //点击图标停止转动,再次点击开始转动
       // var audio=document.getElementById("audio");
       // audio.play()   
       var flag=false;
       $("#icon").click(function(){
           if(!flag){
               //$(this).css({"-webkit-animation-iteration-count":"0"});
               $(this).css({"-webkit-animation-play-state":"paused"});
               //音乐停止
               $("#audio").pause();
               flag=true;
           }else{
               //$(this).css({"-webkit-animation-iteration-count":"infinite"});
               $(this).css({"-webkit-animation-play-state":"running"});
               //音乐播放
               $("#audio").play();
               flag=false;
           }
       })
       	/*项目中运用到写法
           $(".music").click(function(){
               var music = document.getElementById("video");
               if(music.paused){
                   music.play();
                   $(this).removeClass("off");
                   $(this).css({"-webkit-animation-play-state":"running"});
               }else{
                   music.pause();
                   $(this).addClass("off");
                   $(this).css({"-webkit-animation-play-state":"paused"});
               }
           });
           */
   </script>
</html>
  • 2
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
好的,下面是使用 Vue.js 实现一个可以手动控制转动角度的转盘效果的简单示例代码。在这个示例中,我们使用 Vue.js 和 CSS3 的 transform 属性来实现旋转效果,并且可以通过输入框来控制转动角度。 ```html <template> <div class="roulette-container"> <div class="roulette-wheel" :style="{ transform: 'rotate(' + deg + 'deg)'}"></div> <div class="input-group"> <label for="angle">Angle:</label> <input type="number" id="angle" v-model="angle" min="0" max="360"> <button class="btn" @click="spin">Spin</button> </div> </div> </template> <script> export default { data() { return { deg: 0, angle: 0 } }, methods: { spin() { // 将输入的角度添加到当前角度值中 this.deg += parseInt(this.angle); // 重置输入框的值 this.angle = 0; } } } </script> <style> .roulette-container { position: relative; width: 400px; height: 400px; margin: 0 auto; } .roulette-wheel { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: url(./roulette.png) no-repeat center center; background-size: contain; transition: transform 5s ease-in-out; } .input-group { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); display: flex; align-items: center; } .input-group label { margin-right: 10px; } .input-group input { width: 60px; margin-right: 10px; padding: 5px; border: 1px solid #ccc; border-radius: 4px; text-align: center; outline: none; } .btn { padding: 5px 10px; background-color: #f00; color: #fff; border: none; border-radius: 4px; outline: none; cursor: pointer; } </style> ``` 在这个示例中,我们添加了一个输入框和一个 “Spin” 按钮,用于控制旋转角度。在 Vue 组件中,我们使用 `angle` 数据来跟踪输入框中的角度,使用 `deg` 数据来跟踪转盘旋转的角度。通过 `spin` 方法,我们可以将输入框中的角度添加到 `deg` 中,从而实现旋转效果。 需要注意的是,这个示例只是一个简单的实现,仅供参考。如果你需要实现更复杂的转盘效果,可能需要更多的 CSS 和 JavaScript 代码
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值