CSS实现抖音LOGO动画

本文展示了如何使用CSS实现抖音风格的文字特效。通过HTML和CSS代码,演示了三种抖音Logo风格的效果:眩晕文字效果(使用text-shadow和动画)、彩色抖动文字(通过关键帧实现颜色变化)以及经典的"摇屁股"动画(利用position和动画实现位移效果)。

目录

1、效果演示

2、HTML代码

3、实践总结


运行环境:

1、效果演示

2、HTML代码

html 复制代码
<!doctype html>
<html lang="zh" data-hairline="true" class="itcauecng" data-theme="light">
<head>
<meta charSet="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title data-rh="true">CSS 实现抖音LOGO STYLE</title>
<meta name="description" content="CSS 实现抖音LOGO STYLE" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
<meta name="renderer" content="webkit" />
<meta name="force-rendering" content="webkit" />
<link href="https://fonts.googleapis.com/css?family=Anton" rel="stylesheet">
<style>
html {
    background: rgb(29, 29, 29);
}

/** 眩晕文字 */
.n-xy {
    text-shadow: -2px -2px 0 #ff004f, 2px 2px 0 #00f7ef;
    animation: shake-it .5s reverse infinite cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/** 彩色抖动文字 */
.doudong{
    animation: uk-text-shadow-glitch .65s cubic-bezier(1,-1.91,0,2.79) 0s infinite normal both running;
}
@keyframes uk-text-shadow-glitch {
    0% {
       text-shadow: none 
    }
    25% {
       text-shadow: -2px -2px 0 #ff004f,2px 2px 0 #00f7ef 
    }
    50% {
       text-shadow: 2px -2px 0 #ff004f,-2px 2px 0 #00f7ef 
    }
    75% {
       text-shadow: -2px 2px 0 #ff004f,2px -2px 0 #00f7ef 
    }
    100% {
       text-shadow: 2px 2px 0 #ff004f,-2px -2px 0 #00f7ef 
    }
}
@keyframes uk-flicker {
    0% {
        opacity: 0 
    }
    10% {
        opacity: .6;
        transform: scale(.8) 
    }
    20% {
        opacity: 0 
    }
    40% {
        opacity: 1 
    }
    50% {
        opacity: .2;
        transform: scale(1.1) 
    }
    100% {
        opacity: 1;
        transform: scale(1) 
    }
}

/** 摇屁股动画 */
.douyin-style {
    position: relative;
}
.douyin-style-font {
    font-weight: 700;
    width:640px;
    position: relative;
    animation: debounce 1s steps(3) infinite;
    /** font style **/
    font-size: 50px;
    font-style: italic;
    font-weight: bold;
    letter-spacing: 3px;
    font-family: 'Anton', sans-serif;
}
.douyin-style-font .douyin-style-title {
    position: absolute;
    top: 3px;
    left: 3px;
    width: inherit;
}
.douyin-style-font .douyin-style-title:before {
    position: absolute;
    top: -2px;
    left: -2px;
    color: #00f5e7;
    opacity: .8;
    z-index: 2;
    content: attr(data-title);
}
.douyin-style-font .douyin-style-title span{
    position: relative;
    color: #FFF;
    z-index: 3;
    opacity: .9;
}
.douyin-style-font .douyin-style-title:after {
    position: absolute;
    top: 2px;
    left: 2px;
    opacity: .8;
    color: #ff0068;
    z-index: 1;
    content: attr(data-title);
}
.douyin-style-font.shake {
    position: absolute;
    z-index: 9;
    left: var(--shake-offset);
    height: var(--shake-height);
    overflow: hidden;
    background:rgb(29, 29, 29);
    animation: shake-body 1s steps(4) infinite;
    animation-delay: var(--shake-delay);
}
 .douyin-style-font.shake .douyin-style-title {
    animation: shake-content 1s steps(4) infinite;
    animation-delay: var(--shake-delay);
}
@keyframes debounce {
    0% {
        margin-left: 2px;
    }
    0% {
        margin-left: -4px;
    }
}
@keyframes shake-body {
    0% {
        top: 0;
    }
    100% {
        top: 60px;
    }
}
@keyframes shake-content {
    0% {
        margin-top: 0;
    }
    100% {
        margin-top: -60px;
    }
}
</style>
</head>
<body>
    <h2 class="n-xy">欢迎回家 Hello World</h2>
    <h2 class="doudong">欢迎回家 Hello World</h2>
    <div class="douyin-style">
       <div class="douyin-style-font">
          <div class="douyin-style-title" data-title="欢迎回家 Hello World">
             <span>欢迎回家 Hello World</span>
          </div>
       </div>
       <div class="douyin-style-font shake" style="--shake-offset: -2px; --shake-height: 20px;--shake-delay:0s;">
          <div class="douyin-style-title" data-title="欢迎回家 Hello World">
             <span>欢迎回家 Hello World</span>
          </div>
       </div>
       <div class="douyin-style-font shake" style="--shake-offset: -3px; --shake-height: 2px;--shake-delay:0.2s;">
          <div class="douyin-style-title" data-title="欢迎回家 Hello World">
             <span>欢迎回家 Hello World</span>
          </div>
       </div>
       <div class="douyin-style-font shake" style="--shake-offset: -5px; --shake-height: 10px;--shake-delay:0.1s;">
          <div class="douyin-style-title" data-title="欢迎回家 Hello World">
             <span>欢迎回家 Hello World</span>
          </div>
       </div>
    </div>
</body>
</html>

3、实践总结

本文展示了如何使用CSS实现抖音风格的文字特效。通过HTML和CSS代码,演示了三种抖音Logo风格的效果:眩晕文字效果(使用text-shadow和动画)、彩色抖动文字(通过关键帧实现颜色变化)以及经典的"摇屁股"动画(利用position和动画实现位移效果)。

代码中定义了多个动画关键帧,通过调整偏移量、延迟时间和高度参数,模拟出抖音标志性的动态效果。这些效果可以在现代浏览器中运行,为网页添加独特的视觉体验。


附录:

相关推荐
linweidong10 个月前
前端CSS面试题及参考答案
前端面试·css选择器·margin·css动画·前端面经·css兼容·标准盒模型
吉吉安1 年前
CSS实现中心放大动画
前端·css·动画·css动画·css中心放大动画
qbbmnnnnnn1 年前
【CSS Tricks】css动画详解
前端·css·css动画·css animation
m0_631653311 年前
CSS变换
前端·css·css动画·2d变换·3d变换
艾恩小灰灰2 年前
探索CSS中的贝塞尔曲线cubic-bezier()函数:掌握自定义动画曲线的艺术
前端·css·css3·贝塞尔曲线·css动画·cubic-bezier·css函数
艾恩小灰灰2 年前
探索CSS3文本效果:打造魅力无限的网页排版
前端·css·css3·web前端·css动画·css文本效果
迂 幵2 年前
分享7款前端直接使用的项目动画特效(附在线演示)
前端·css动画·源码分享·动画特效·jquery特效·canvas特效·项目动画
设计师工作日常2 年前
有趣的CSS - 多彩变化的按钮
前端·css·ui·ux·css动画·按钮
设计师工作日常2 年前
有趣的CSS - css loading动画
前端·css·loading·css动画