Home > Web Front-end > HTML Tutorial > Make interesting dynamic wavy lines of text with HTML/CSS

Make interesting dynamic wavy lines of text with HTML/CSS

藏色散人
Release: 2021-08-27 14:37:24
Original
2348 people have browsed it

In the previous article " is very practical! CSS implements the dynamic effect of pressing when the button is clicked》Introduced how to use CSS to display the dynamic effect of pressing when the button is clicked. Friends in need can go and learn about it~

This article will show you how to use HTML/CSS to create an interesting dynamic wavy text line effect!

Let’s look directly at the complete code example:

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background-color: rgb(74, 152, 255);
        }

        .wavy {
            position: relative;
        }

        .wavy span {
            position: relative;
            display: inline-block;
            color: #fff;
            font-size: 2em;
            text-transform: uppercase;
            animation: animate 2s ease-in-out infinite;
            animation-delay: calc(0.1s * var(--i));
        }

        @keyframes animate {
            0% {
                transform: translateY(0px);
            }

            20% {
                transform: translateY(-20px);
            }

            40%,
            100% {
                transform: translateY(0px);
            }
        }
    </style>
</head>

<body>
<div class="wavy">
    <span style="--i:1">P</span>
    <span style="--i:2">H</span>
    <span style="--i:3">P</span>
    <span style="--i:4">中</span>
    <span style="--i:5">文</span>
    <span style="--i:6">网</span>
    <span style="--i:7">开</span>
    <span style="--i:8">班</span>
    <span style="--i:9">啦</span>
    <span style="--i:10">~</span>
    <span style="--i:11">快</span>
    <span style="--i:12">学</span>
    <span style="--i:13">起</span>
    <span style="--i:14">来</span>
    <span style="--i:15">~</span>
    <span style="--i:16">~</span>
    <span style="--i:17">~</span>

</div>
</body>
</html>
Copy after login

The effect is as follows:

GIF 2021-8-27 星期五 下午 2-30-58.gif

You can directly copy the above code, Run the demo locally.

Here are some key attributes:

  • The text-transform attribute controls the case of text.

  • The animation property is a shorthand property:

animation-name:规定需要绑定到选择器的 keyframe 名称。。    
animation-duration:规定完成动画所花费的时间,以秒或毫秒计。    
animation-timing-function:规定动画的速度曲线。    
animation-delay:规定在动画开始之前的延迟。    
animation-iteration-count:规定动画应该播放的次数。    
animation-direction:规定是否应该轮流反向播放动画。
Copy after login
  • Animation can be created through @keyframes rules.

语法:@keyframes animationname {keyframes-selector {css-styles;}}
参数animationname必需:定义动画的名称。
参数keyframes-selector必需:动画时长的百分比。
合法的值:
0-100%
from(与 0% 相同)
to(与 100% 相同)
参数css-styles必需:一个或多个合法的 CSS 样式属性。
Copy after login

PHP Chinese website platform has a lot of video teaching resources. Welcome everyone to learn "css Video Tutorial"!

The above is the detailed content of Make interesting dynamic wavy lines of text with HTML/CSS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template