#4.0 - 4.1Transitions
4์ฅ์์๋ ๊ณ ๊ธ CSS๋ฅผ ๋ฐฐ์ธ ๊ฒ์ด๋ค. animation, transition, transformation ๋ฑ
Transition : ์ด๋ค ์ํ์์ ๋ค๋ฅธ ์ํ๋ก์ "๋ณํ"๋ฅผ ์ ๋๋ฉ์ด์ ์ผ๋ก ๋ง๋๋ ๋ฐฉ๋ฒ
* transition ์์ฑ์ state๊ฐ ์๋ ์์์ ๋ถ์ฌ์ผ ํ๋ค. โ ์ ๋๋ฉ์ด์ ์ ์ฃผ๊ณ ์ถ์ ์์๊ฐ state์ ์์ด์ผ ๋ณํ๊ฐ ์๊ธด๋ค.
<style>
a {
color: wheat;
background-color: tomato;
border-radius: 5px;
transition: all 5s eas-in-out;
}
a:hover {
color: tomato;
background-color: wheat;
}
</style>
ease-in function : ๋ธ๋ผ์ฐ์ ์๊ฒ ์ ๋๋ฉ์ด์ ์ด ์ด๋ป๊ฒ ๋ณํํ๋์ง ๋งํด์ฃผ๋ ๊ฒ
- linear : ์์๋ถํฐ ๋๊น์ง ์ผ์ ํ ์๋
- ease-in : ์์๊ณผ ๋์ด ๋น ๋ฆ
- ease-out : ์์๊ณผ ๋์ด ๋๋ฆผ
- ease-in-out : ์์์ด ๋น ๋ฅด๊ณ ๋์ด ๋๋ฆผ
<ease-in function ํจ๊ณผ ์ฌ์ดํธ โฝ >
https://matthewlein.com/tools/ceaser
Ceaser - CSS Easing Animation Tool - Matthew Lein
Choose an easing type and test it out with a few effects. If you donโt quite like the easing, grab a handle and fix it. When youโre happy, snag your code and off you go. Now that we can use CSS transitions in all the modern browsers, letโs make them
matthewlein.com
* all : ๋ณํ ์์๋ฅผ ํ ๋ฒ์ ๋ค๋ฃธ.
>>๊ฐ๊ฐ ๋ฐ๋ก ๋ค๋ฃจ๊ณ ์ถ์ผ๋ฉด ์ฝค๋ง(,)๋ฅผ ์จ์ ์ฌ๋ฌ transition์ ์ค ์ ์๋ค.
#4.2 Transformations
Transformation: ๋ง ๊ทธ๋๋ก ํ ์์๋ฅผ ๋ณํ(transform)์ํฌ ์ ์๋ค.
**border-radius: 50% โ ์์ด ๋๋ค.!!
์) transform: rotateX(n deg) โ X์ถ์ผ๋ก n๋ ํ์ (+Y / Z)
transform: sclaeX(n deg) โ X์ถ ๊ธฐ์ค์ผ๋ก ํฌ๊ธฐ ๋ณ๊ฒฝ
- transform์ box element๋ฅผ ๋ณํ์ํค์ง ์๋๋ค. ์ฆ, ๋ค๋ฅธ ํ์ ์์๋ค์ ์ํฅ์ ๋ผ์น์ง ์๋๋ค.
- margin, padding์ด ์ ์ฉ๋์ง ์๋๋ค. ์ผ์ข ์ 3D์ด๊ธฐ ๋๋ฌธ
- transform๊ณผ transition์ ์กฐํฉํ์ฌ ๋ ๋ฉ์ง ์ ๋๋ฉ์ด์ ์ ๋ง๋ค ์ ์๋ค.
<style>
img {
border: 5px solid black;
border-radius: 50%;
transition: transform 2s ease-in-out;
}
img:hover {
transform: rotate(360deg) scale(1.5);
}
</style>
#4.3 - 4.4 Animations
๋ง์ฐ์ค๋ฅผ ์ฌ๋ฆฌ๊ฑฐ๋, transition ์์ด ๊ณ์ ์ฌ์๋๋ ์ ๋๋ฉ์ด์ ์ ๋ง๋ค๊ธฐ ์ํด์?
@keyframes ์ ๋๋ฉ์ด์
์ด๋ฆ {
<!--์ด๋์์๋ถํฐ ์ด๋๊น์ง ์ ๋๋ฉ์ด์
์ ์ ์ฉํ ์ง-->
from { }
to { }
}
<style>
@keyframes thisisAnimation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
img {
border: 5px solid black;
border-radius: 50%;
animation: thisisAnimation 5s ease-in-out;
}
</style>
* animation: ... ๋์ infinite๋ฅผ ์ฐ๋ฉด ์ ๋๋ฉ์ด์ ๋ฌดํ ๋ฐ๋ณต.
๋๋
@keyframes ์ ๋๋ฉ์ด์
์ด๋ฆ {
0% { }
50% { }
100% { }
}
์ด์ฒ๋ผ from to ๋ง๊ณ 1,2,3,4,5...10 ํน์ 0%, 25%, 50%, 75%, 100% ๊ฐ์ด ์ฌ๋ฌ ๋จ๊ณ๋ก ๋๋์ด ์ ๋๋ฉ์ด์ ์ ๋ง๋ค ์ ์๋ค.
โ ์ ๋๋ฉ์ด์ ์ด ๋๋๋ฉด ๋ค์ ์ฒ์์ผ๋ก ๋์๊ฐ์ง ์๊ณ , ๊ณ์ ์ด์ด์ง๋๋ก ๋ง๋ค ์ ์๋ค.
#4.5 Media Queries
media query : ์ค์ง CSS๋ง์ ์ด์ฉํด์ ์คํฌ๋ฆฐ์ ์ฌ์ด์ฆ๋ฅผ ์ ์ ์๋ ๋ฐฉ๋ฒ
@media screen and (max-width: n px) { }
min ์ฌ์ด์ฆ์ max ์ฌ์ด์ฆ๋ฅผ ์กฐ์ ํ์ฌ ์คํฌ๋ฆฐ ์ฌ์ด์ฆ์ ๋ฐ๋ผ ์คํ์ผ์ ๋ณํ๋ฅผ ์ค ์ ์๋ค.
<style>
@media screen and (max-width: 600px) {
div {
background-color: violet;
}
}
@media screen and (min-width: 601px) and (max-width: 1200px) {
div {
background-color: wheat;
}
}
@media screen and (min-width: 1200px) {
div {
background-color: hotpink;
}
}
</style>
@media screen์ (orientation: landscape | portrait) ์ ์ถ๊ฐํ๋ฉด ํธ๋ํฐ์ด ๊ฐ๋ก๋ชจ๋์ธ์ง ์ธ๋ก๋ชจ๋์ธ์ง ๊ตฌ๋ณํ ์ ์๋ค.
*landscape = ๊ฐ๋ก, protrait = ์ธ๋ก


#4.6 Media Queries Recap
- media query ์์ ์ํ๋ ๋ชจ๋ CSS๋ฅผ ์์ฑํ ์ ์๋ค.
- media query๋ and๋ฅผ ์จ์ ์ฐ๊ฒฐ๋๋ค.
- "min-width"๋ ์ปดํจํฐ, ํธ๋ํฐ ๋ชจ๋ ์ ์ฉ๋์ง๋ง "min-device-width"๋ ์ค์ง ํธ๋ํฐ์๋ง ์ ์ฉ๋๋ค.
- @media print๋ฅผ ์ด์ฉํ๋ฉด ๋ธ๋ผ์ฐ์ ์ธ์ ํ์ด์ง์์์ ์์ฑ์ ๋ณ๊ฒฝํ ์ ์๋ค.