首页 > 代码库 > [TypeStyle] Use TypeStyle keyframes to create CSS animations
[TypeStyle] Use TypeStyle keyframes to create CSS animations
We cover CSS keyframes and how to create them using TypeStyle. We then show how to use the keyframes function to create an animation. We also discuss a few other CSS properties in the animation
namespace.
import {style, keyframes, classes} from ‘typestyle‘;import * as React from ‘react‘;import * as ReactDOM from ‘react-dom‘;const fadeAnimationName = keyframes({ from: {opacity: 0}, to: {opacity: 1}});const fadeAnimationClassName = style({ animationName: fadeAnimationName, animationDuration: ‘2s‘});const coloringAnimationName = keyframes({ ‘0%‘: {color: ‘black‘}, ‘50%‘: {color: ‘pink‘}, ‘100%‘: {color: ‘red‘}});const fontColoringAnimationClassName = style({ fontSize: ‘20px‘, animationName: coloringAnimationName, animationDuration: ‘2s‘, animationIterationCount: ‘infinite‘});const App = () => ( <div className={classes( fadeAnimationClassName, fontColoringAnimationClassName )}> Hello World! </div>);ReactDOM.render( <App />, document.getElementById(‘root‘));
[TypeStyle] Use TypeStyle keyframes to create CSS animations
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。