您好,登錄后才能下訂單哦!
如何在微信小程序中實現(xiàn)一個音樂播放頁面的布局?相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
樣式布局代碼
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 }) } } })
看完上述內容,你們掌握如何在微信小程序中實現(xiàn)一個音樂播放頁面的布局的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。