CSS100Day(23)-动态字体动画设计
1123 字
6 分钟
CSS100Day(23)-动态字体动画设计
设计简介
关键点如下
-
知识点1:
transform-origin可以使用animation动画,前面学习过使用margin auto实现,这里使用该方式更科学 -
知识点2:突然出现可以设计为一个隐藏元素先覆盖显示元素,然后隐藏元素
scale变0
效果展示
Collect
not things
moments
实现代码和步骤
HTML部分
<div class="frame"> <div class="circle"></div> <div class="line left"></div> <div class="line right"></div> <div class="bracket left"></div> <div class="bracket right"></div> <div class="small top">Collect</div> <div class="small bottom">not things</div> <div class="big">moments</div> <div class="hide top"></div> <div class="hide bottom"></div></div>CSS部分
.frame { width: 400px; height: 400px; box-shadow: 1px 2px 10px 0px rgba(0, 0, 0, 0.3); overflow: hidden; background: #e16d6c; color: #fff; position: relative;}
.circle { position: absolute; z-index: 10; top: 175px; left: 175px; background: #fff; border-radius: 50%; width: 50px; height: 50px; animation: circle 1s ease-in-out forwards;}
.line { position: absolute; z-index: 10; width: 150px; height: 4px; top: 198px; background: #fff; transform: scaleX(0);
&.left { left: 50px; transform-origin: 100% 50%; animation: lines 1s ease-in-out 0.8s, line-left 1s steps(1) 0.8s; }
&.right { right: 50px; transform-origin: 0% 50%; animation: lines 1s ease-in-out 0.8s, line-right 1s steps(1) 0.8s; }}
.big { position: absolute; z-index: 5; top: 173px; width: 400px; text-align: center; font-weight: 800; font-size: 50px; color: #fff; line-height: 50px; text-transform: uppercase;}
.hide { position: absolute; z-index: 7; width: 400px; height: 50px; background: #e16d6c; left: 0; animation: reveal 0.4s ease-out 1.7s; animation-fill-mode: both;
&.top { bottom: 49%; transform-origin: 50% 0%; }
&.bottom { top: 49%; transform-origin: 50% 100%; }}
.bracket { position: absolute; z-index: 10; height: 70px; width: 4px; top: 165px; background: #fff; animation: bracket 0.4s ease-out 1.7s both;
&::before, &::after { position: absolute; display: block; content: ""; width: 25px; height: 4px; background: #fff; }
&.left { left: 50px;
&::before { top: 0; left: 0; transform-origin: 0% 50%; animation: bracket-line 0.2s ease-out 2.1s; animation-fill-mode: both; }
&::after { bottom: 0; left: 0; transform-origin: 0% 50%; animation: bracket-line 0.2s ease-out 2.1s; animation-fill-mode: both; } }
&.right { right: 50px;
&::before { top: 0; right: 0; transform-origin: 100% 50%; animation: bracket-line 0.2s ease-out 2.1s; animation-fill-mode: both; }
&::after { bottom: 0; right: 0; transform-origin: 100% 50%; animation: bracket-line 0.2s ease-out 2.1s; animation-fill-mode: both; } }}
.small { position: absolute; z-index: 10; width: 400px; text-align: center; left: 0; font-weight: 300; font-size: 30px; color: #fff; line-height: 30px; text-transform: uppercase;
&.top { top: 140px; animation: small-top 0.5s ease-out 2.2s both; }
&.bottom { bottom: 140px; animation: small-bottom 0.5s ease-out 2.2s both; }}
@keyframes circle { 0% { scale: 1; } 50% { scale: 1.2; } 90%, 100% { scale: 0; }}
@keyframes lines { 0% { transform: scaleX(0); } 50% { transform: scaleX(1); } 100% { transform: scaleX(0); }}
@keyframes line-left { 0% { transform-origin: 100% 50%; } 50% { transform-origin: 0% 50%; }}
@keyframes line-right { 0% { transform-origin: 0% 50%; } 50% { transform-origin: 100% 50%; }}
@keyframes bracket { from { transform: scaleY(0); } to { transform: scaleY(1); }}
@keyframes bracket-line { from { transform: scaleX(0); } to { transform: scaleX(1); }}
@keyframes reveal { 0% { transform: scaleY(1); } 100% { transform: scaleY(0); }}
@keyframes small-top { 0% { opacity: 0; transform: translateX(-50px); } 100% { opacity: 1; transform: translateX(0); }}
@keyframes small-bottom { 0% { opacity: 0; transform: translateX(50px); } 100% { opacity: 1; transform: translateX(0); }}
@keyframes big { from { transform: scaleY(0); } to { transform: scaleY(1); }}分享给其他人
如果该文章对您有帮助,欢迎分享给其他人阅读!
复制链接
相关文章
推荐筛选
1
CSS100Day(28)-振铃动画
设计灵感 振铃动画
2
CSS100Day(24)-一个按钮动画
设计灵感 依然使用svg-dasharray转圈,使用checkbutton实现点击动画加载
3
CSS100Day(10)-SVG旋转动画
设计灵感 巧妙应用SVG的
4
CSS100Day(2)-菜单按钮动画
设计灵感 菜单按钮都见过,但是三根条动画实现,关键利用no-animation初始化时候关闭回复动画
5
CSS100Day(25)-翻转动画另一种实现
设计灵感 翻转动画另一种实现
随机文章
随机推荐