javascript - css动画需要居中,不干扰首页布局
问题描述
HTML CSS AND JAVASCRIPT in a nutshell
The code needs to be optimized so that it fits into a website above a contact form and text should be in the center without disturbing the wordpess website layout .Please help
<head>
<meta charset="UTF-8">
<title></title>
<style>
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
font-family: helvetica, arial, sans-serif;
font-size: 100px;
font-weight: bold;
letter-spacing: -0.4rem;
}
.break {
display: flex;
flex-wrap: wrap;
}
.mask {
transform: rotate(0deg);
overflow: hidden;
position: relative;
white-space: nowrap;
animation: wobble 7s infinite;
}
@keyframes wobble {
35% {
transform: rotate(360deg);
}
100% {
transform: rotate(360deg);
}
}
.mask div {
position: relative;
}
nav ul {
display: flex;
}
nav li {
display: block;
}
nav a {
padding: 20px;
text-decoration: none;
background-color: lemonchiffon;
margin-right: 1px;
}
</style>
</head>
<body>
<div class="break">
GET IN TOUCH
</div>
<script>
const col_count = 20;
let txt = document.querySelector(".break"),
w = txt.getBoundingClientRect().width,
h = txt.getBoundingClientRect().height,
chunk_size = Math.ceil(w/col_count),
row_count = Math.ceil(h/chunk_size);
txt.style.width = chunk_size*col_count+"px";
let html = `<div class='mask'><div>${txt.innerHTML}</div></div>`;
txt.innerHTML = "";
for(let i=0; i<row_count; i++) {
for(let j=0; j<col_count; j++) {
txt.innerHTML += html;
let index = j+i*col_count;
}
}
let masks = document.querySelectorAll(".mask");
let inMasks = document.querySelectorAll(".mask div");
for(let i=0; i<row_count; i++) {
for(let j=0; j<col_count; j++) {
let index = j+i*col_count;
masks[index].style.width = chunk_size+"px";
masks[index].style.height = chunk_size+"px";
masks[index].style.overflow = "hidden";
masks[index].style.animationDelay = `${index*20}ms`;
inMasks[index].style.left = -j*(chunk_size) + "px";
inMasks[index].style.top = -i*(chunk_size) + "px";
}
}
</script>
</body>
</html>
代码取自链接 - https://codepen.io/punishyourmachine/pen/pQZMZa?page=4
要求~
1.需要居中
2.代码需要插入到联系我们表格上方以展示它。
3.Plz 也改变颜色
4.你可以通过这个或去 codepen 编辑器更正代码
解决方案
编辑 .break 类如下
.break {
display: flex;
flex-wrap: wrap;
margin:0 auto; /* center */
color:#F95300; /* color */
}
推荐阅读
- javascript - 如何从另一个函数调用本地函数?
- go - 从 OAuth 请求客户端获取令牌
- php - 在子类问题中设置父类变量
- windows - 将文件重命名为更长的名称
- c# - 关于从数据库中锁定某些文档
- php - Typo3 8.7.x / Extbase:在自己的扩展中扩展 RealUrl
- haskell - 使用基于整数的新类型进行代数 Haskell
- c# - FluentAssertions .ShouldNotThrow() 方法在 ver5.4.2 中找不到,但在 ver4.19.4 中找到
- regex - 仅选择第一个 Result /.*(?!.*==>.*).*(\n) / gm
- nsis - 如何向 NSIS 安装程序添加新页面