


Teach you step by step how to use css3 to add animation effects to text (with code)
In the previous article "Teach you step by step how to use css to add flame effects to text (detailed code explanation)", I introduced you how to use css to add flame effects to text. The following article will introduce to you how to use css3 to add animation effects to text. Let’s see how to do it together.
#It can be seen in this type of website that both text and pictures change with the specified time. The principle of the powerful primary key of CSS3 is very simple. It mainly uses the animation attribute in CSS to realize the animation effect of text for everyone to see.
Code steps
1. First use the html
framework.
Create a new document and write code using <div class="animate box">. <pre class='brush:php;toolbar:false;'><div class="animate box"></div></pre><p style="margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;text-indent:0;padding:0 0 0 0 ;background:rgb(255,255,255)">2. The general framework has been written, <code><div> tags. Next add text code to it. Put the code in <code><span></span>
. You can write whatever you want in the text. I wrote "css3 to achieve simple text animation effect"
<div class="animate box"> <span>css3实现简单的文字动画效果</span> </div>
ok, the html code is done
3. The core part of css3 implementation: CSS animation and font styles. The
animate
attribute is used to bind the animation to the div
element, measured in pixels. When the animate
attribute is defined for an element, its child elements get the perspective effect, not the element itself. Let me show you how to write the code below. First, add the <style type="text/css"><style></style>
between the head
tags and then add the Code examples for font size, margins, layout (setting width and height on elements) of text entered in the style
tag.
.animate { font-size: 40px; margin: 100px 0 0; } .animate span { display: inline-block; }
4. Box box
The box box model refers to: intuitively laying out elements on a web page. Each box has a content area and optional surrounding margins, margins and frame. Let me show you how to write the code below. The method of adding <style type="text/css"><style></style>
between the above head tags is the same as the style
tag. Enter the color, opacity, offset of the text, code example.
.box span { color: #fff; opacity: 0; transform: translate(-150px, 0) scale(.5); animation: leftRight 1s forwards; }
5, Add @keyframes
to the boxanimation
, because this is the div
element that moves at a constant speed, code example.
@keyframes leftRight { 40% { transform: translate(30px, 0) scale(.7); opacity: 1; color: #000; } 60% { color: #fff; } 80% { transform: translate(0) scale(2); opacity: 0; } 100% { transform: translate(0) scale(1); opacity: 1; }
##ok, css is done【End】Recommended learning:
The above is the detailed content of Teach you step by step how to use css3 to add animation effects to text (with code). For more information, please follow other related articles on the PHP Chinese website!

If you've ever had to display an interactive animation during a live talk or a class, then you may know that it's not always easy to interact with your slides

With Astro, we can generate most of our site during our build, but have a small bit of server-side code that can handle search functionality using something like Fuse.js. In this demo, we’ll use Fuse to search through a set of personal “bookmarks” th

I wanted to implement a notification message in one of my projects, similar to what you’d see in Google Docs while a document is saving. In other words, a

Some months ago I was on Hacker News (as one does) and I ran across a (now deleted) article about not using if statements. If you’re new to this idea (like I

Since the early days of science fiction, we have fantasized about machines that talk to us. Today it is commonplace. Even so, the technology for making

I remember when Gutenberg was released into core, because I was at WordCamp US that day. A number of months have gone by now, so I imagine more and more of us

The idea behind most of web applications is to fetch data from the database and present it to the user in the best possible way. When we deal with data there

Let's do a little step-by-step of a situation where you can't quite do what seems to make sense, but you can still get it done with CSS trickery. In this


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

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

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

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