search
HomeWeb Front-endFront-end Q&AHow to implement font enlargement and reduction animation in css3

Implementation method: 1. Use the "@keyframes" rule and the "transform:scale (scale);" statement to create a font enlargement and reduction animation; 2. Use "font element {animation: animation name time infinite;} ” statement applies the scaling animation to the font element.

How to implement font enlargement and reduction animation in css3

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

In css, you can use animation attributes, "@keyframes" rules, transform: scale() to achieve font amplification Zoom out animation

Example:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style>
			/*css部分*/
			@keyframes scaleDraw {

				/*定义关键帧、scaleDrew是需要绑定到选择器的关键帧名称*/
				0% {
					transform: scale(1);/*开始为原始大小*/
				}

				25% {
					transform: scale(1.5);/*放大1.1倍*/
				}

				50% {
					transform: scale(1);
				}

				75% {
					transform: scale(1.5);
				}
			}

			.ballon {
				width: 150px;
				height: 200px;
				margin: 100px auto;
				-webkit-animation-name: scaleDraw;/*关键帧名称*/
				-webkit-animation-timing-function: ease-in-out;/*动画的速度曲线*/
				-webkit-animation-iteration-count: infinite;/*动画播放的次数*/
				-webkit-animation-duration: 5s;/*动画所花费的时间*/

				/*可以简写为*/
				/* animation: scaleDraw 5s ease-in-out infinite; */
				/* -webkit-animation: scaleDraw 5s ease-in-out infinite; */
			}
		</style>
	</head>

	<body>
		<div class="ballon">欢迎来到PHP中文网</div>
	</body>
</html>

How to implement font enlargement and reduction animation in css3

##Instructions:

animation(animation attribute)

PropertyDescriptionCSS@keyframesDefine an animation. The animation name defined by @keyframes is used by animation-name. 3animationComposite attribute. Retrieves or sets the animation effects applied to the object. 3animation-nameRetrieve or set the animation name applied to the object, which must be used in conjunction with the rule @keyframes, because the animation name is determined by @keyframes definition3animation-durationRetrieves or sets the duration of the object animation3animation-timing-functionRetrieves or sets the transition type of the object animation3animation-delayRetrieve or set the delay time of object animation3##animation-iteration-countanimation-directionanimation-play-state
Retrieve or set the loop of object animation Times 3
Retrieve or set whether the object animation moves in reverse direction in the loop 3
Retrieve or set the state of the object animation 3
@keyframes

is a rule of CSS3 that can be used to define the behavior of a period of CSS animation and create simple animations. @keyframes rules are composed of a set of encapsulated CSS style rules that describe how attribute values ​​change over time.

@keyframes animation-name {keyframes-selector {css-styles;}}

    keyframes-selector: Defines the percentage of animation, it is between 0% and 100%. An animation can contain many selectors.
  • Then, using different CSS animation properties, you can control many different aspects of the animation, including the number of animation iterations, whether to alternate between the start and end values, and the animation Whether it should run or pause. Animations can also delay their start time.

@keyframe rules consist of the keyword "@keyframe", followed by an identifier giving the name of the animation (which will be referenced using animation-name), followed by a set of style rules (delimited by curly braces) . The animation is then applied to the element by using the identifier as the value of the animation-name attribute.

Syntax:

/* 定义动画*/
@keyframes 动画名称{
    /* 样式规则*/
}
/* 将它应用于元素 */
.element {
    animation-name: 动画名称(在@keyframes中已经声明好的);
    /* 或使用动画简写属性*/
    animation: 动画名称 1s ...
}

Inside the curly braces, we need to define keyframes or waypoints that specify the value of the property being animated at a specific point during the animation . This allows us to control intermediate steps in the animation sequence.

(Learning video sharing:

css video tutorial

, web front-end)

The above is the detailed content of How to implement font enlargement and reduction animation in css3. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What type of audio files can be played using HTML5?What type of audio files can be played using HTML5?Apr 30, 2025 pm 02:59 PM

The article discusses HTML5 audio formats and cross-browser compatibility. It covers MP3, WAV, OGG, AAC, and WebM, and suggests using multiple sources and fallbacks for broader accessibility.

Difference between SVG and Canvas HTML5 element?Difference between SVG and Canvas HTML5 element?Apr 30, 2025 pm 02:58 PM

SVG and Canvas are HTML5 elements for web graphics. SVG, being vector-based, excels in scalability and interactivity, while Canvas, pixel-based, is better for performance-intensive applications like games.

Is drag and drop possible using HTML5 and how?Is drag and drop possible using HTML5 and how?Apr 30, 2025 pm 02:57 PM

HTML5 enables drag and drop with specific events and attributes, allowing customization but facing browser compatibility issues on older versions and mobile devices.

What is the difference between <meter> tag and <progress> tag?What is the difference between <meter> tag and <progress> tag?Apr 30, 2025 pm 02:56 PM

The article discusses the differences between HTML's <meter> and <progress> tags, used for displaying scalar values and task progress, respectively.

Convert the below data into Tabular format in HTML5?Convert the below data into Tabular format in HTML5?Apr 30, 2025 pm 02:54 PM

Here is the converted data into a tabular format using HTML5, including examples and strategies for responsive design, best practices for styling, and semantic HTML5 tags used within a table structure:<!DOCTYPE html> <html lang=&

Define Image Map?Define Image Map?Apr 30, 2025 pm 02:53 PM

The article discusses image maps in web design, their benefits like enhanced navigation and engagement, and tools for their creation.

Is the <datalist> tag and <select> tag same?Is the <datalist> tag and <select> tag same?Apr 30, 2025 pm 02:52 PM

The article discusses the differences between <datalist> and <select> tags, focusing on their functionality, user interaction, and suitability for different web development scenarios.

What is the difference between <figure> tag and <img> tag?What is the difference between <figure> tag and <img> tag?Apr 30, 2025 pm 02:50 PM

The article discusses the differences between HTML's <figure> and <img> tags, focusing on their purposes, usage, and semantic benefits. The main argument is that <figure> provides better structure and accessi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

MantisBT

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.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor