首页 > Web开发 > 详细

[TypeStyle] Use TypeStyle keyframes to create CSS animations

时间:2017-06-07 09:22:37      阅读:303      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/Answer1215/p/6954416.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!