当前位置:网站首页>reduce函数构建炫耀字体,字体动画。
reduce函数构建炫耀字体,字体动画。
2022-07-19 12:08:00 【Jason–json】
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
padding: 0px;
margin: 0px;
}
body {
width: 300vh;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: #34495e;
}
div {
font-size: 3em;
font-weight: bold;
text-transform: uppercase;
color: #9b599b;
}
div>span {
position: relative;
display: inline-block;
}
.color {
animation-name: color;
animation-duration: 1s;
animation-iteration-count: 2;
animation-timing-function: linear;
animation-direction: alternate;
}
@keyframes color {
50% {
color: #f1c40f;
transform: scale(2);
}
to {
color: #e7c3ce;
transform: scale(0.5);
}
}
</style>
</head>
<body>
<div>shihuayingkejishukejifazhanyouxiangongsi</div>
</body>
<script>
{
let divs = document.querySelector("div")
// console.log(divs.textContent)
let arrDiv = [...divs.textContent] //获取文本内容
console.log(arrDiv)
arrDiv.reduce((pre, cur, index) => { //reduce方法循环
if (pre === index) {
divs.innerHTML = ''
}
let span = document.createElement("span")//获取拆分后的文本添加标签
span.innerHTML = cur
divs.appendChild(span)
span.addEventListener("mouseover", () =>
span.classList.add("color"),
console.log(pre, cur)
)
// 监听动画结束 移除类
span.addEventListener("animationend", function () {
span.classList.remove("color")
})
}, 0)
}
</script>
</html>
特别感谢后盾人,学习更多前端知识请登录后盾人
边栏推荐
- Was expecting double quote to start field name error
- [bzoj2393] cirno's perfect math classroom
- Use masonry to realize width adaptation and height adaptation of controls (including uitableview) according to content
- Conway's Law -- organization decides products, and domain drives design
- Uicollectionviewcell and uitableviewcell are left blank up, down, left and right
- Is there a function similar to ifnull in flinksql?
- Southern Cass 10.1 software installation package download and installation tutorial
- Difference Between Accuracy and Precision
- Eolink 和 JMeter 接口测试对比
- JSD-2204-微博项目(完结)-Day16
猜你喜欢
全球1000+研究员在Twitter直播训练超大模型??
面试被问MySQL 如何去重,还有谁不会?
雲原生核心技術之:Service Mesh 的實現—— Istio
Cloud Native Core Technology: Service Mesh Implementation - istio
DevOps 实践多年,最痛的居然是?
【历史上的今天】7 月 7 日:C# 发布;Chrome OS 问世;《仙剑奇侠传》发行
ICLR 2022 | GNNAsKernel: 能提升任意GNN表达能力的通用框架
梅科尔工作室-华为14天鸿蒙设备开发实战笔记五
Improve the mirror station configuration information - mirror station experience Officer
云原生核心技术之:Service Mesh 的实现—— Istio
随机推荐
高端纯电SUV顶级产品,AION LX Plus与蔚来ES6如何选?
Literary and artistic calculation Ji of provincial election and professional training
Southern Cass 10.1 software installation package download and installation tutorial
请问,现在有什么短期的理财产品值得买?
flink sql 配置 kafka 连锁一个多分区的topic 一直没连上也没报错,单分区的没问题
科技云报道:零信任和SASE有什么不一样?答案其实并不重要
[JSOI2007]重要的城市
最基本的排序
【历史上的今天】7 月 19 日:IMAP 协议之父出生;Project Kotlin 公开亮相;CT 成像实现新突破
Mysql on duplicate key update用法及优缺点
JSD-2204-微博项目(完结)-Day16
Provincial selected and specially trained [haoi2009] caterpillar
The resources in the target folder cannot be loaded by the program
基于Xlinx的时序分析与约束(1)----什么是时序分析?什么是时序约束?什么又是时序收敛?
Decorator solves typeerror: 'nonetype' object is not callable
图论复习usaco2006jan gold分离的路径
CB Insights发布AI行业七大趋势:合成数据、多模态AI崛起
康威定律——组织决定产品,领域驱动设计
使用Masonry实现控件(包括UITableView)根据内容进行宽度自适应和高度自适应
Analysis of e-commerce user behavior data