0-360도로 돌아가는 애니메이션을 제작해보자
const rotateAnimation = keyframes` 0% { transform:rotate(0deg); border-radius: 0; } 50% { border-radius: 100px; } 100% { transform:rotate(360deg); border-radius: 0; } `;
10s linear infinite
: 10초 동안 재생해주세요import React from 'react';
import ReactDOM from "react-dom"
import App from './App';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
import styled, {keyframes} from "styled-components";
const Wrapper = styled.div`
display: flex;
height: 100vh;
width: 100vw;
justify-content: center;
align-items: center;
`;
// 0도 -> 360도 회전하는 애니메이션
const rotateAnimation = keyframes`
0% {
transform:rotate(0deg);
border-radius: 0;
}
50% {
border-radius: 100px;
}
100% {
transform:rotate(360deg);
border-radius: 0;
}
`;
const Emoji = styled.span`
font-size: 36px;
`;
// 1초동안 애니메이션이 발생
// active: 클릭 시 애니메이션
const Box = styled.div`
height:200px;
width: 200px;
background-color: tomato;
animation:${rotateAnimation} 10s linear infinite;
${Emoji}{
&:hover {
font-size: 98px;
}
&:active {
opacity:0;
}
}
`;
// input required: attrs 안에 넣으면 됨
const Input = styled.input.attrs({ required: true, minLength: 10})`
background-color: tomato;
border:0;
`;
function App() {
return (
<Wrapper as="header">
<Box></Box>
</Wrapper>
)
}
export default App;