【发布时间】:2020-01-19 22:41:09
【问题描述】:
我是 React 新手,专门尝试使用样式化组件和关键帧。
我正在尝试让主页标题 h1 滑入。
我遵循了一些文档,但我觉得有些东西丢失了或者我有问题。
代码如下:
//Home.js
import React from "react";
import styled, { keyframes } from 'styled-components';
const Heading = keyframes`
0% { top: -3.125em; }
100% { top: 3em;
`;
const home = styled.div`
min-height: 95vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 1.5em;
color: white;
`;
const homeHeader = styled.div`
h1 {
font-weight: lighter;
animation: Heading;
animation-duration: 3s;
animation-fill-mode: forwards;
}
// Animation
animation: ${Heading}
animation-duration: 3s;
animation-fill-mode: forwards;
`;
export const Home = () => (
<div className="home">
<header className="homeHeader">
<h1>Welcome to Freight Mule</h1>
</header>
</div>
);
export default Home;
任何有助于理解如何让关键帧和动画工作的帮助都会非常有帮助。
【问题讨论】:
标签: css reactjs css-animations styled-components keyframe