html修改列表内的audio样式,如何修改H5中的audio样式

HTML

我要吃肉肉

何曼婷 - 我要吃肉肉

CSS

.btn-audio{

width: 100%;

height: 5.2rem;

border: 1px solid #ebebeb;

background-color: #fdfdfd;

margin-bottom: 1rem;

margin-top: 1rem;

position: relative;

}

.mp3Box{

width: 2.8rem;

height: 2.8rem;

position: absolute;

top: 1.2rem;

left: 1.2rem;

background:url("image/close.png") no-repeat center bottom;

background-size:cover;

z-index: 100;

}

JS

$(function(){

//播放完毕

$('#mp3Btn').on('ended', function() {

console.log("音频已播放完成");

$('.mp3Box').css({'background':'url(image/close.png) no-repeat center bottom','background-size':'cover'});

});

//播放器控制

var audio = document.getElementById('mp3Btn');

audio.volume = .3;

$('.mp3Box').click(function() {

event.stopPropagation();//防止冒泡

if(audio.paused){ //如果当前是暂停状态

$('.mp3Box').css({'background':'url(image/open.png) no-repeat center bottom','background-size':'cover'});

audio.play(); //播放

}else{//当前是播放状态

$('.mp3Box').css({'background':'url(image/close.png) no-repeat center bottom','background-size':'cover'});

audio.pause(); //暂停

}

});

})

修改前:

0a317a245a338c3ed31542e0045ae671.png

修改后:

facbd5c2c65f2e1bee421c1122445ded.png

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值