In the process of learning CSS3, I found that many cool effects can be easily achieved using CSS3 attributes. Animation is a common attribute in CSS3 animation effects. Now let's learn how to use this property to create the following button effect with a streamer when the mouse is on the button~ Before that, let me briefly introduce the usage of the animation attribute. background-image: linear-gradient(to left , #EAD6EE,#A0F1EA,rgb(124, 241, 241),#e3a5f0,#EAD6EE); background-size: 400%; Analysis: Now the background is a gradient of three colors, which is four times the size of the div, so the div only displays one color. The frame animation effect is used to control the movement of the background, and the animation attribute can make it flow continuously. Step 3 : Use frame animation to control the horizontal movement of the background positioning. (@keyframes function: define animation. Simple animation can directly use the keywords from and to. Complex animation can use 0%~100% to set the corresponding animation effect in segments, that is, transition from one state to another) @keyframes run{ 100%{ background-position: 400% 0px; } } Then use the pseudo class hover to achieve the animation effect when the mouse moves up~ @keyframes run{ 100%{ background-position: 400% 0px; } } .div2:hover{ animation: run 4s linear 0s infinite; } Case complete code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> .div2{ position:absolute; left: calc(50% - 150px); top: calc(50% - 150px); width: 300px; height: 100px; border-radius: 50px; text-align: center; background-color:aqua; line-height: 100px; background-image: linear-gradient(to left , #EAD6EE,#A0F1EA,rgb(124, 241, 241),#e3a5f0,#EAD6EE); background-size: 400%; } @keyframes run{ 100%{ background-position: 400% 0px; } } .div2:hover{ animation: run 4s linear 0s infinite; } </style> </head> <body> <div class="div2"> Let's Go </div> </body> </html> Simple CSS3 streamer animation effect is realized This is the end of this article about how to use animation in CSS3 to achieve the streamer button effect. For more relevant CSS3 animation streamer button content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope that everyone will support 123WORDPRESS.COM in the future! |
<<: Install Docker on CentOS 7
>>: About browser compatibility issues encountered and solutions (recommended)
When I was studying CSS recently, I found that I ...
What we are simulating now is a master-slave syst...
1. Overview There are three ways to create a Dock...
This article records the installation and configu...
GNU Parallel is a shell tool for executing comput...
1. Disk partition: 2. fdisk partition If the disk...
What are XHTML tags? XHTML tag elements are the b...
Create a new table CREATE TABLE `person` ( `id` i...
Table of contents Preface 👀 Start researching 🐱🏍...
Table of contents 0x0 Introduction 0x1 Installati...
Written in front I have been writing a special to...
Table of contents Object Object Definition Iterat...
Table of contents 1. Basic Use 2. Working Princip...
Prerequisites Compose is a tool for orchestrating...
Learning objectives: The two functions parseInt()...