码迷,mamicode.com
首页 > 其他好文 > 详细

[React] Animate your user interface in React with styled-components and "keyframes"

时间:2017-08-17 10:31:34      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:class   spin   for   com   ack   default   margin   bsp   out   

In this lesson, we learn how to handle CSS keyframe animations in styled-components, via the ‘keyframes‘ helper.

 

import React from "react";
import styled, { keyframes } from "styled-components";

const morph = keyframes`
  0% { border-radius: 5px; }
  50% { border-radius: 50%; }
  100% { border-radius: 5px; }
`;

const spin = keyframes`
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
`;

const Ball = styled.div`
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto;
  background-color: #08aeea;
  background-image: linear-gradient(0deg, #08aeea 0%, #2af598 100%);
  animation: ${morph} 1s linear infinite, ${spin} 1s ease-in-out infinite;
`;

const App = () => <Ball />;

export default App;

 

[React] Animate your user interface in React with styled-components and "keyframes"

标签:class   spin   for   com   ack   default   margin   bsp   out   

原文地址:http://www.cnblogs.com/Answer1215/p/7377510.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!