2022/04/07 styled component에서 CSS애니메이션 적용하기
2022. 4. 7. 15:58ㆍProject : 근의 공식(Muscle Formula)
https://medium.com/@matt.readout/adding-css-animations-with-styled-components-6c191c23b6ba
Adding CSS Animations with Styled Components
I love using styled-components in a React project. The ability to write CSS right in the component file is so simple and straightforward…
medium.com
참고예제
import styled, { keyframes } from 'styled-components'
const Breathe = () => {
return (
<Container>
<Circle />
</Container>
)
}
export default Breathe
//keyframe 변수명 선언
const breatheAnimation = keyframes`
0% { height: 100px; width: 100px; }
30% { height: 400px; width: 400px; opacity: 1 }
40% { height: 405px; width: 405px; opacity: 0.3; }
100% { height: 100px; width: 100px; opacity: 0.6; }
`
//적용할 부분에 animation-name으로 넣어준다
const Circle = styled.div`
height: 100px;
width: 100px;
border-style: solid;
border-width: 5px;
border-radius: 50%;
border-color: black;
animation-name: ${breatheAnimation};
animation-duration: 8s;
animation-iteration-count: infinite;
`
이밖에 보통 CSS에서 적용할 때는 다음과 같이 쓴다
https://www.w3schools.com/css/css3_animations.asp
CSS Animations
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
www.w3schools.com
'Project : 근의 공식(Muscle Formula)' 카테고리의 다른 글
| 2022/04/08 alert 창 라이브러리 SweetAlert 사용법 (2) | 2022.04.08 |
|---|---|
| 2022/04/07 PM2 with Typescript (0) | 2022.04.07 |
| 2022/04/06 Radio 버튼 응용 (0) | 2022.04.06 |
| 2022/04/06 editable div태그에 placeholder 넣는 법 (0) | 2022.04.06 |
| 2022/04/05 스크롤 상위로 올라가고 싶을 때 (0) | 2022.04.05 |