如何在微信小程序中实现一个音乐播放页面的布局?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
样式布局代码
wxml:
<view class="page_music"> <view class='icon {{isPlay?"rotateAu":""}}' mode="widthFix"> </view> <view class="tools"> <view class="last" bindtap="last"> </view> <view class='{{isPlay?"pause":"play"}}' bindtap="play"> </view> <view class="next" bindtap="next"> </view> </view> <view class="volume"> <view class="volumeIcon"> </view> <view class="sl"> <slider min='0' max='10' step="1" value="0" bindchange="slide"/> </view> </view> </view>
wxss:
.page_music{ position: absolute; width: 100%; height: 80%; } .icon{ position: relative; width: 500rpx; height: 500rpx; top:5%; left: 125rpx; background-image: url(""); /*放入光碟图片*/ background-size: 100% 100%; background-repeat:no-repeat; background-position: center; } .tools{ position: relative; width: 80%; height: 10%; top: 10%; left: 10%; } .last{ width: 100rpx; height: 100rpx; position: absolute; left: 0; top:0; background-image: url(""); /*放入上一首图标*/ background-size: 100% 100%; background-repeat:no-repeat; background-position: center; } .play{ width: 100rpx; height: 100rpx; position: absolute; left: 42%; top:0; background-image: url(""); /*放入播放图标*/ background-size: 100% 100%; background-repeat:no-repeat; background-position: center; } .pause{ width: 100rpx; height: 100rpx; position: absolute; left: 42%; top:0; background-image: url(""); /*放入暂停图标*/ background-size: 100% 100%; background-repeat:no-repeat; background-position: center; } .next{ width: 100rpx; height: 100rpx; position: absolute; right: 0; top:0; background-image: url(""); /*放入下一首图标*/ background-size: 100% 100%; background-repeat:no-repeat; background-position: center; } .volume{ position: relative; width: 80%; height: 10%; top: 20%; left: 10%; } .volumeIcon{ position: absolute; left: 0; width: 80rpx; height: 80rpx; top:0; background-image: url(""); /*放入音量图标*/ background-size: 100% 100%; background-repeat:no-repeat; background-position: center; } .sl{ position: absolute; right: 0; width: 80%; height: 100%; top: 0; background-image: url(""); /*放入滑动条背景图片*/ background-size: 100% 100%; background-repeat:no-repeat; background-position: center; } .rotateAu{ animation: rotate 3s linear infinite; } @keyframes rotate{ from{transform: rotate(0deg)} to{transform: rotate(360deg)} }
js:
Page({ data:{ isPlay:false, }, play:function(e){ if(this.data.isPlay==true) { this.setData({ isPlay:false }) } else { this.setData({ isPlay:true }) } } })
看完上述内容,你们掌握如何在微信小程序中实现一个音乐播放页面的布局的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。