码迷,mamicode.com
首页 > Web开发 > 详细

css3可控旋转音乐播放按钮

时间:2020-03-17 08:39:10      阅读:56      评论:0      收藏:0      [点我收藏+]

标签:play   imu   remove   sharp   min   script   lis   tar   rem   

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>星律网在线邀请</title>
<style>
*{ margin:0; padding:0; list-style:none;}
#lanren{ width:44px; position:absolute; z-index:99999; right:0; top:0;}
#lanren #audio-btn{width: 44px;height: 44px; margin:10px auto;background-size: 100% 100%;}
#lanren .on{background: url(‘/skin/yqx/images/music.gif‘) no-repeat 0 0;-webkit-animation: rotating 1.2s linear infinite;animation: rotating 1.2s linear infinite;}
#lanren .off{background: url(‘/skin/yqx/images/music.gif‘) no-repeat 0 0;}
@-webkit-keyframes rotating {
	from{
		-webkit-transform: rotate(0deg);
		-moz-transform: rotate(0deg);
		-ms-transform: rotate(0deg);
		-o-transform: rotate(0deg);
    	transform: rotate(0deg);
	}
	to{
		-webkit-transform: rotate(360deg);
		-moz-transform: rotate(360deg);
		-ms-transform: rotate(360deg);
		-o-transform: rotate(360deg);
		transform: rotate(360deg);
	}
}
@keyframes rotating {
    from{
        -webkit-transform: rotate(0deg);
		-moz-transform: rotate(0deg);
		-ms-transform: rotate(0deg);
		-o-transform: rotate(0deg);
        transform: rotate(0deg);
    }
    to{
        -webkit-transform: rotate(360deg);
		-moz-transform: rotate(360deg);
		-ms-transform: rotate(360deg);
		-o-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}
</style>
<script src="/html_mre/layui/jquery-1.11.0.min.js"></script>
</head>
<body>
    <div id="lanren">
        <div id="audio-btn" class="on" onClick="lanren.changeClass(this,‘media‘)">
            <audio loop="loop" src="images/bg.mp3" id="media" preload="preload"></audio>
        </div>
    </div>
    <script>
        var lanren = {
            changeClass: function (target,id) {
                var className = $(target).attr(‘class‘);
                var ids = document.getElementById(id);
                (className == ‘on‘)? $(target).removeClass(‘on‘).addClass(‘off‘): $(target).removeClass(‘off‘).addClass(‘on‘);
                (className == ‘on‘)? ids.pause(): ids.play();
            },
            play:function(){
                document.getElementById(‘media‘).play();
            }
        }
        lanren.play();
    </script>
</body>
</html>

  

css3可控旋转音乐播放按钮

标签:play   imu   remove   sharp   min   script   lis   tar   rem   

原文地址:https://www.cnblogs.com/thinkbig/p/12508287.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!