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
Three useful codes to help visitors remember your...
This article mainly introduces CSS circular hollo...
Development Pain Points During the development pr...
Below is the code that Shiji Tiancheng uses to ca...
1. golang:latest base image mkdir gotest touch ma...
border-radius:10px; /* All corners are rounded wi...
1. Introduction to Navicat 1. What is Navicat? Na...
To connect Node-red to the database (mysql), you ...
Table of contents Preface zx library $`command` c...
A Brief Discussion on the Navigation Window in If...
This article example shares the specific code of ...
【SQL】SQL paging query summary The need for paging...
First, what is database partitioning? I wrote an ...
Log in to MySQL first shell> mysql --user=root...
Source: http://www.ruoyi.vip/ import Vue from ...