javascript - 如何将“关键帧”css 应用于 React 组件中的特定类?
问题描述
我有一个名为ComingSoon
. 这是我的 React 应用程序的其他组件的一个组件。
import React, { Component } from 'react';
import '../Styles/ComingSoon.css';
class ComingSoon extends Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<div className="comingSoon-container">
<span className="comingSoon-text1">Coming</span>
<span className="comingSoon-text2">Soon</span>
</div>
</div>
)
}
}
export default ComingSoon;
这是该组件的我的 CSS 文件名ComingSoon.css
:
.comingSoon-container {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
}
.comingSoon-container span {
text-transform: uppercase;
display: block;
}
.comingSoon-text1 {
color: black;
font-size: 65px;
font-weight: 700;
letter-spacing: 12px;
margin-bottom: 20px;
background: white;
position: relative;
animation: text 3s 1;
}
.comingSoon-text2 {
font-size: 50px;
color: #2b8bc6;
}
@keyframes text {
0% {
color: white;
margin-bottom: -60px;
}
30% {
letter-spacing: 30px;
margin-bottom: -60px;
}
85% {
letter-spacing: 12px;
margin-bottom: -60px;
}
}
如何确保 CSS 样式@keyframes text
不适用于我的应用程序的其他组件,而仅适用于具有 className 的内容的特定组件comingSoon-container
。
解决方案
推荐阅读
- angular - 尝试使用带有 ngFor 的异步管道来获取数据并动态显示角度 6
- dita - 为什么 DITA Open Toolkit PDF 插件重命名图像 href 属性?
- python - 你能从 Pandas 绘图调用中导出直方图 y 值吗?
- python - Django elasticsearch-dsl 在 pre_save 上更新 M2M
- node.js - createReadStream 不采用 blob url?
- python - why is "a" not definied when i definied it in def?
- python-3.x - pandas 使用分类字符串值对 x 轴进行排序
- json - 比较 2 个 JSON 文件并在值匹配时创建一个新键
- r - How do I convert hex to numbers keeping the sign (+/-) in R?
- c++ - 打印 reference_wrapper 的向量