Note: This demo is tested in the mini program environment and is applicable to other h5 and pc web pages. You only need to change the mini program unit and tag name to the universal ones and adapt it according to your needs. The general idea is to lay out four identical squares in a T-shaped pattern and combine them with the rotation attribute. HTML structure <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 Styles .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); } Note: If the text area is not inline-block, the rotation property will not take effect! Button click event 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 volume') break case 'volDes': console.log('weaken the volume') break default: console.log('ok') } } Operation effect Summarize The above is the CSS imitation remote control button introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! |
<<: Demystifying the HTML 5 Working Draft
>>: VUE Getting Started Learning Event Handling
Before starting the main text, I will introduce s...
This article shares the specific code of vue echa...
Concurrency Functions time for i in `grep server ...
Preface In JavaScript, you need to use document.q...
Table of contents Prune regularly Mirror Eviction...
Preface: I believe that those who need to underst...
Preface: Integer is one of the most commonly used...
Preface In daily development, we often need to pe...
This article example shares the specific code of ...
Enable the service when you need it, and disable ...
This article mainly introduces an example of Vue ...
Table of contents Tutorial Series 1. Backup strat...
In the past few years, I have been moving back an...
Deploy redis in docker First install Docker in Li...
rep / egrep Syntax: grep [-cinvABC] 'word'...