CSS模仿遙控器按鈕

注:本demo在小程序環(huán)境中測(cè)試,其他h5,pc網(wǎng)頁通用,只需將小程序單位和標(biāo)簽名改成通用的即可,并按照自己的需求做適配即可。
大體思路:四個(gè)相同的正方形田字形布局,配合旋轉(zhuǎn)屬性即可。
html結(jié)構(gòu)
<view class="button-group"> <view class="outter-circle"> <view class="inner-parts brown" bindtap="button" data-type="volAdd"> <text class="rotate">+</text> </view> <view class="inner-parts silver" bindtap="button" data-type="chaAdd"> <text class="rotate">+</text> </view> <view class="inner-parts blue" bindtap="button" data-type="chaDes"> <text class="rotate">-</text> </view> <view class="inner-parts gold" bindtap="button" data-type="volDes"> <text class="rotate">-</text> </view> <view class="inner-circle" bindtap="button" data-type="ok"> <text class="ok rotate">ok</text> </view> </view> </view>
css樣式
.button-group { padding-top: 20rpx; width: 300rpx; height: 300rpx; background-color: pink; } .outter-circle { position: relative; margin-left: 10rpx; width: 280rpx; height: 280rpx; background-color: lightcyan; border-radius: 100%; overflow: hidden; transform-origin: center; transform: rotate(45deg); } .inner-parts { float: left; width: 140rpx; height: 140rpx; line-height: 140rpx; text-align: center; } .silver { background-color: silver; } .gold { background-color: gold; } .blue { background-color: blue; } .brown { background-color: brown; } .inner-circle { position: absolute; margin-top: 70rpx; margin-left: 70rpx; width: 140rpx; height: 140rpx; line-height: 140rpx; text-align: center; border-radius: 100%; background-color: lightblue; } .rotate { display: inline-block; transform: rotate(-45deg); }
注:文字區(qū)域若不inline-block,旋轉(zhuǎn)屬性將不生效!
按鈕點(diǎn)擊事件
button: function(e) { var buttonType = e.currentTarget.dataset.type console.log(buttonType) switch (buttonType) { case 'chaAdd': console.log('backward the channel') break case 'chaDes': console.log('forward the channel') break case 'volAdd': console.log('strengthen the volumn') break case 'volDes': console.log('weaken the volumn') break default: console.log('ok') } }
運(yùn)行效果
總結(jié)
以上所述是小編給大家介紹的CSS模仿遙控器按鈕,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
JS+CSS3實(shí)現(xiàn)提交按鈕發(fā)送信封動(dòng)畫特效源碼
JS+CSS3實(shí)現(xiàn)提交按鈕發(fā)送信封動(dòng)畫特效源碼是一款js基于css3提交按鈕動(dòng)畫,郵件發(fā)送按鈕點(diǎn)擊信封飛入動(dòng)畫特效。本段代碼可以在各個(gè)網(wǎng)頁使用,有需要的朋友可以直接下載使用2018-02-26CSS3實(shí)現(xiàn)的多組創(chuàng)意互動(dòng)式開關(guān)切換按鈕動(dòng)畫特效源碼
CSS3實(shí)現(xiàn)的創(chuàng)意互動(dòng)式開關(guān)切換按鈕特效源碼是一段實(shí)現(xiàn)了多組創(chuàng)意的CSS3動(dòng)畫按鈕特效,如:白天黑夜、難過開心、高亮等等,非常實(shí)用,歡迎有需要的朋友前來下載使用2018-01-26CSS使用classList實(shí)現(xiàn)兩個(gè)按鈕樣式的切換
在一些頁面我們需要使用兩個(gè)按鈕來回切換,怎么實(shí)現(xiàn)這樣的功能呢?下面小編給大家?guī)砹薈SS使用classList實(shí)現(xiàn)兩個(gè)按鈕樣式的切換效果,需要的朋友跟隨腳本之家小編一起學(xué)習(xí)2018-01-24css3點(diǎn)擊按鈕水波紋氣泡動(dòng)畫特效源碼
css3點(diǎn)擊按鈕水波紋氣泡動(dòng)畫特效源碼是一款紅色按鈕,當(dāng)鼠標(biāo)點(diǎn)擊按鈕四周發(fā)射水波紋氣泡動(dòng)畫效果,效果非常逼真。本段代碼可以在各個(gè)網(wǎng)頁使用,有需要的朋友可以直接下載使2018-01-23CSS3美化單選/復(fù)選/開關(guān)按鈕樣式特效源碼
CSS3美化單選/復(fù)選/開關(guān)按鈕樣式特效源碼是一款純CSS3的單選框,復(fù)選框,開關(guān)按鈕UI庫,實(shí)現(xiàn)了按鈕可選和按鈕不可選的效果,非常不錯(cuò),歡迎有需要的朋友前來下載使用2017-12-21CSS3實(shí)現(xiàn)單選和多選按鈕美化樣式特效源碼
CSS3實(shí)現(xiàn)單選和多選按鈕美化樣式特效源碼是一款可以和多種字體圖標(biāo)結(jié)合使用的按鈕表單特效。本段代碼可以在各個(gè)網(wǎng)頁使用,有需要的朋友可以直接下載使用2017-09-26純CSS3實(shí)現(xiàn)的炫酷checkbox復(fù)選框美化庫checkboxes.css(含開關(guān)按鈕美化
checkboxes.css是一款純CSS3炫酷checkbox復(fù)選框美化庫。checkboxes.css可以通過在HTML代碼中簡(jiǎn)單的class配置,生成多種不同效果的checkbox美化樣式,其中包括復(fù)選框按鈕美2017-09-05CSS3鼠標(biāo)hover按鈕過渡動(dòng)畫特效
這是一款CSS3鼠標(biāo)hover按鈕過渡動(dòng)畫效果。當(dāng)鼠標(biāo)滑過即按鈕可出現(xiàn)各種的hover覆蓋動(dòng)畫特效,效果簡(jiǎn)單方便,歡迎下載2017-08-10