How to use pure CSS to implement a moving hand (source code attached)
The content of this article is about how to use pure CSS to realize a moving hand (source code attached). It has certain reference value. Friends in need can refer to it. I hope it will be useful to you. Helps.
Effect preview
.finger elements in the container represent 5 fingers, The
.thumb element represents the thumb, and the
.palm element represents the palm:
<div> <span></span> <span></span> <span></span> <span></span> <span></span> <span></span> </div>Centered display:
body { margin: 0; height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(white, lightcyan); }defines the container size, where
outline The attribute is an auxiliary line:
.hand { width: 16em; height: 8em; font-size: 10px; outline: 1px dashed black; }Draw the palm:
.hand { position: relative; color: darksalmon; } .palm { position: absolute; width: 8em; height: 6em; background-color: currentColor; border-radius: 1em 4em; right: 0; }Draw the outline of the thumb:
.thumb { position: absolute; width: 9.6em; height: 3.2em; background-color: currentColor; border-radius: 3em 2em 2em 1em; right: 0; bottom: 1em; transform-origin: calc(100% - 2em) 2em; transform: rotate(-20deg); border-bottom: 0.2em solid rgba(0, 0, 0, 0.1); border-left: 0.2em solid rgba(0, 0, 0, 0.1); }Draw the nail on the thumb:
.thumb::before { content: ''; position: absolute; width: 1.9em; height: 1.9em; background-color: rgba(255, 255, 255, 0.3); border-radius: 60% 10% 10% 30%; bottom: -0.3em; left: 0.5em; border-right: 0.1em solid rgba(0, 0, 0, 0.1); }Draw the second half of the index finger close to the palm:
.finger:not(:first-child) { position: absolute; width: 6.4em; height: 3.5em; background-color: currentColor; right: 5.2em; bottom: 4em; transform-origin: 100% 2em; transform: rotate(10deg); }Draw the first half of the index finger:
.finger:not(:first-child)::before { content: ''; position: absolute; width: 9em; height: 3em; background-color: currentColor; right: 4.2em; top: 0.2em; border-radius: 2em; transform-origin: calc(100% - 2em) 2em; transform: rotate(-60deg); }Set subscript variables for the other 4 fingers except the thumb , gradually shrinking and deepening in color from the index finger to the little finger:
.finger:not(:first-child) { --scale: calc(1 - (5 - var(--n)) * 0.2); transform: rotate(10deg) scale(var(--scale)); filter: brightness(calc(100% - (5 - var(--n)) * 10%)); } .finger:nth-child(2) { --n: 2; } .finger:nth-child(3) { --n: 3; } .finger:nth-child(4) { --n: 4; } .finger:nth-child(5) { --n: 5; }Use pseudo elements to draw the shadow of the hand:
.hand::before { content: ''; position: absolute; width: 14em; height: 4.5em; background-color: black; border-radius: 4em 1em; top: 4em; filter: blur(1em) opacity(0.3); }Increase the animation effect of finger tapping on the desktop:
.finger:not(:first-child) { animation: tap-upper 1.2s ease-in-out infinite; animation-delay: calc((var(--n) - 2) * 0.1s); } @keyframes tap-upper { 0%, 50%, 100% { transform: rotate(10deg) scale(var(--scale)); } 40% { transform: rotate(50deg) scale(var(--scale)); } }Finally, don’t forget to delete the guide lines. Done! Related recommendations:
How to use pure CSS to achieve the effect of a pair of scissors (source code attached)
How to use pure CSS to achieve stripes Illusion animation effect (with source code)
The above is the detailed content of How to use pure CSS to implement a moving hand (source code attached). For more information, please follow other related articles on the PHP Chinese website!

What does it look like to refactor your own code? John Rhea picks apart an old CSS animation he wrote and walks through the thought process of optimizing it.

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

@keyframesispopularduetoitsversatilityandpowerincreatingsmoothCSSanimations.Keytricksinclude:1)Definingsmoothtransitionsbetweenstates,2)Animatingmultiplepropertiessimultaneously,3)Usingvendorprefixesforbrowsercompatibility,4)CombiningwithJavaScriptfo

CSSCountersareusedtomanageautomaticnumberinginwebdesigns.1)Theycanbeusedfortablesofcontents,listitems,andcustomnumbering.2)Advancedusesincludenestednumberingsystems.3)Challengesincludebrowsercompatibilityandperformanceissues.4)Creativeusesinvolvecust

Using scroll shadows, especially for mobile devices, is a subtle bit of UX that Chris has covered before. Geoff covered a newer approach that uses the animation-timeline property. Here’s yet another way.

Let’s run through a quick refresher. Image maps date all the way back to HTML 3.2, where, first, server-side maps and then client-side maps defined clickable regions over an image using map and area elements.

The State of Devs survey is now open to participation, and unlike previous surveys it covers everything except code: career, workplace, but also health, hobbies, and more.

CSS Grid is a powerful tool for creating complex, responsive web layouts. It simplifies design, improves accessibility, and offers more control than older methods.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
