λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
κ°œμΈκ³΅λΆ€/HTML5 + CSS3

[HTML+CSS][CSS3와 μ• λ‹ˆλ©”μ΄μ…˜] 03 - νŠΈλžœμ§€μ…˜

by πŸ‡λ°•λ΄‰λ΄‰πŸ‡ 2020. 7. 30.

 

 

 

[HTML+CSS][CSS3와 μ• λ‹ˆλ©”μ΄μ…˜] 02 - λ³€ν˜•κ³Ό κ΄€λ ¨λœ 속성듀

[HTML+CSS][CSS3와 μ• λ‹ˆλ©”μ΄μ…˜] 01 - λ³€ν˜• [HTML+CSS][λ‹€μž¬λ‹€λŠ₯ν•œ CSS3 μ„ νƒμž] 03 - 가상 ν΄λž˜μŠ€μ™€ 가상 μš”μ†Œ [HTML+CSS][λ‹€μž¬λ‹€λŠ₯ν•œ CSS3 μ„ νƒμž] 02 - 속성 μ„ νƒμž [HTML+CSS][λ‹€μž¬λ‹€λŠ₯ν•œ CSS3 μ„ νƒμž] 01 - μ—°..

onelight-stay.tistory.com

 

μ—¬νƒœκΉŒμ§€ λ‹¨μˆœν•œ λ³€ν˜•μ— λŒ€ν•΄μ„œλ§Œ μ•Œμ•„λ³΄μ•˜λ‹€λ©΄

μ΄λ²ˆμ—λŠ” μ™„μ „νžˆ λ‹€λ₯Έ μŠ€νƒ€μΌλ‘œ λ°”κΏ€ 수 μžˆλŠ”

νŠΈλžœμ§€μ…˜μ— λŒ€ν•΄μ„œ μ•Œμ•„λ³΄μž.

 

 


 

 

νŠΈλžœμ§€μ…˜ (transition)

 

μ‹œκ°„μ— λ”°λΌμ„œ μ›Ή μš”μ†Œμ˜ μŠ€νƒ€μΌ 속성이 μ‘°κΈˆμ”© λ°”λ€ŒλŠ” 것이닀.

 

 

 


 

 

transition-property 속성 : νŠΈλžœμ§€μ…˜ μ μš©ν•  속성 지정

 

νŠΈλžœμ§€μ…˜μ„ μ–΄λŠ μ†μ„±μ— μ μš©ν•  κ²ƒμΈμ§€ μ„ νƒν•˜λŠ” κ²ƒμœΌλ‘œ 

ν•΄λ‹Ή 속성을 μ‚¬μš©ν•˜μ§€ μ•Šμ„ κ²½μš°, 

λͺ¨λ“  속성이 νŠΈλžœμ§€μ…˜ λŒ€μƒμ΄ λ˜κ³  

νŠΉμ • μ†μ„± μ΄λ¦„을 μž…λ ₯ν•˜λ©΄ κ·Έ μ†μ„±μ— νŠΈλžœμ§€μ…˜μ΄ μ μš©λœλ‹€.

 

 


 

 

transition-duration 속성 : νŠΈλžœμ§€μ…˜ μ§„ν–‰μ‹œκ°„ 지정

 

ν•΄λ‹Ή μ†μ„±μ„ μ‚¬μš©ν•΄ μ •ν•΄λ†“은 μ‹œκ°„ λ™μ•ˆ μ†μ„±μ΄ μžμ—°μŠ€λŸ½κ²Œ λ°”λ€ŒλŠ” μ• λ‹ˆλ©”μ΄μ…˜ νš¨κ³Όλ‘œ 

초(seconds) λ˜λŠ” λ°€λ¦¬μ΄ˆ(milliseconds)둜 λ‚˜νƒ€λ‚Έλ‹€.


μ΄λ•Œ, νŠΈλžœμ§€μ…˜ λŒ€μƒμ΄ λ˜λŠ” μ†μ„±μ΄ μ—¬λŸ¬ κ°œλΌλ©΄ 

μ‰Όν‘œλ‘œ κ΅¬λΆ„ν•΄ μ—¬λŸ¬ κ°œλ₯Ό μ§€μ •ν•  μˆ˜ μžˆλ‹€.

 

 

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>transition-duration</title>
    <style>
        .trduration {
            width: 100px;
            height: 100px;
            background-color: blue;
            border: 2px black solid;
            -webkit-transition-property: width, height;
		    -moz-transition-property: width, height;
		    -o-transition-property: width, height;
		    transition-property: width, height; /* νŠΈλžœμ§€μ…˜ μ μš©λŒ€μƒ : λ„ˆλΉ„μ™€ 높이 */
		    -webkit-transition-duration: 2s, 1s;
		    -moz-transition-duration: 2s, 1s;
		    -o-transition-duration: 2s, 1s;
		    transition-duration: 2s, 1s; /* λ„ˆλΉ„λŠ” 2초, λ†’μ΄λŠ” 1μ΄ˆλ§Œμ— 적용 */
        }
        .trduration:hover {
            width: 200px;
            height: 120px;
        }
    </style>
</head>
<body>
    <h3>정해진 μ‹œκ°„ λ™μ•ˆ 높이와 λ„ˆλΉ„ λ°”κΎΈκΈ°</h3>
    <div class="trduration"></div>
</body>
</html>

 

 

transition-propertyμ—μ„œ μ§€μ •ν•œ μ†μ„±μ˜ κ°œμˆ˜μ™€ transition-durationμ—μ„œ μ§€μ •ν•œ μ‹œκ°„μ˜ κ°œμˆ˜κ°€ μΌμΉ˜ν•  κ²½μš°
속성 κ°’μ—μ„œ μ§€μ •ν•œ μˆœμ„œλŒ€λ‘œ μ‹œκ°„을 μ μš©ν•  μˆ˜ μžˆλŠ”데,
λ§Œμ•½ μ†μ„±μ˜ κ°œμˆ˜μ™€ μ‹œκ°„μ˜ κ°œμˆ˜κ°€ μΌμΉ˜ν•˜μ§€ μ•Šμ„ κ²½μš° 

transition-duration이 transition-property의 κ°œμˆ˜μ—
맞게 μˆœμ„œλŒ€λ‘œ λ°˜λ³΅ μ μš©ν•΄ μ£Όλ©΄ λœλ‹€.

 

 

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>transition-duration</title>
    <style>
        .trduration2 {
            width: 100px;
            height: 100px;
            background-color: red;
            border: black 2px solid;
            text-align: center;
            -webkit-transition-property: background-color, transform, width, height;
            -moz-transition-property: background-color, transform, width, height;
            -o-transition-property: background-color, transform, width, height;
            transition-property: background-color, transform, width, height;
            -webkit-transition-duration: 2s, 3s;
		    -moz-transition-duration: 2s, 3s;
		    -o-transition-duration: 2s, 3s;
            transition-duration: 2s 3s; /* νŠΈλžœμ§€μ…˜ μ μš©λŒ€μƒ λ²ˆκ°ˆμ•„κ°€λ©° 적용 */
        }
        .trduration2:hover {
            background-color: pink; /* 2초 걸쳐 νŠΈλžœμ§€μ…˜ */
            -webkit-transform: rotate(180deg);
		    -moz-transform: rotate(180deg);
		    -o-transform: rotate(180deg);
		    -ms-transform: rotate(180deg);
            transform: rotate(180deg); /* 3초 걸쳐 νŠΈλžœμ§€μ…˜ */
            width: 200px; /* 2초 걸쳐 νŠΈλžœμ§€μ…˜ */
            height: 200px; /* 3초 걸쳐 νŠΈλžœμ§€μ…˜ */
        }
    </style>
</head>
<body>
    <h3>정해진 μ‹œκ°„ λ™μ•ˆ λ°°κ²½ 색과 νšŒμ „, 높이, λ„ˆλΉ„ λ°”κΎΈκΈ°</h3>
    <div class="trduration2"><h1>λ„ν˜•</h1></div>
</body>
</html>

 

 


 

 

transition-timing-function 속성 : νŠΈλžœμ§€μ…˜ 속도 곑선 지정

 

μ‹œμž‘κ³Ό μ€‘κ°„, λμ—μ„œμ˜ μ†λ„λ₯Ό μ§€μ •ν•΄ μ†λ„ κ³‘선을 λ§Œλ“€μ–΄ μ£ΌλŠ” κ²ƒμœΌλ‘œ
속도 κ³‘선은 λ―Έλ¦¬ μ •ν•΄μ§„ ν‚€μ›Œλ“œλ‚˜ '베지에 κ³‘μ„ '을 μ΄μš©ν•΄ ν‘œν˜„ν•œλ‹€.

 

 

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>transition-timing-function</title>
    <style>
        #tfunction div{
            float: left;
            width: 100px;
            height: 50px;
            margin: 5px 10px;
            padding: 5px;
            color: white;
            background-color: rgb(160, 80, 120);
            border-radius: 5px;
            text-align: center;
            font-weight: bold;
        }
        #tfunction:hover div {height: 400px;}
        #tfunction .linear1 {
            -webkit-transition: 3s linear;
            -moz-transition: 3s linear;
            -o-transition: 3s linear;
            transition: 3s linear;
        }
        #tfunction .ease1 {
            -webkit-transition: 3s ease;
            -moz-transition: 3s ease;
            -o-transition: 3s ease;
            transition: 3s ease;
        }
        #tfunction .ease-in1 {
            -webkit-transition: 3s ease-in;
            -moz-transition: 3s ease-in;
            -o-transition: 3s ease-in;
            transition: 3s ease-in;
        }
        #tfunction .ease-out1 {
            -webkit-transition: 3s ease-out;
            -moz-transition: 3s ease-out;
            -o-transition: 3s ease-out;
            transition: 3s ease-out;
        }
        #tfunction .ease-in-out1 {
            -webkit-transition: 3s ease-in-out;
            -moz-transition: 3s ease-in-out;
            -o-transition: 3s ease-in-out;
            transition: 3s ease-in-out;
        }
    </style>
</head>
<body>
    <h3>νŠΈλžœμ§€μ…˜ 속도 곑선 속성값</h3>
    <div id="tfunction">
        <div class="linear1">linear</div>
        <div class="ease1">ease</div>
        <div class="ease-in1">ease-in</div>
        <div class="ease-out1">ease-out</div>
        <div class="ease-in-out1">ease-in-out</div>
    </div>
</body>
</html>

 

 


 

 

transition-delay 속성 : 지연 μ‹œκ°„ μ„€μ •

 

νŠΈλžœμ§€μ…˜μ΄ μ–Έμ œλΆ€ν„° μ‹œμž‘ν•  κ²ƒμΈμ§€λ₯Ό μ„€μ •ν•˜λŠ” κ²ƒμœΌλ‘œ
μ§€μ •ν•œ μ‹œκ°„λ§ŒνΌ κΈ°λ‹€λ Έλ‹€κ°€ νŠΈλžœμ§€μ…˜μ΄ μ‹œμž‘λœλ‹€.

 

 

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>transition-delay</title>
    <style>
        #trdelay {
            position: relative;
            width: 500px;
            height: 150px;
            margin: 0 auto;
            border: 2px solid gray;
            border-radius: 30px;
            padding: 20px;
        }
        #trdelay:hover .box {
            -webkit-transform: rotate(720deg);
            -moz-transform: rotate(720deg);
            -ms-transform: rotate(720deg);
            -o-transform: rotate(720deg);
            transform: rotate(720deg);
            margin-left: 420px;

        }
        .box {
            font-size: 12px;
            position: relative;
            width: 60px;
            height: 60px;
            margin-bottom: 10px;
            background-color: lightgray;
        }
        .box p {
            text-align: center;
            padding-top: 4px;
        }
        #no-delay {
            -webkit-transition-duration: 3s;
            -moz-transition-duration: 3s;
            -o-transition-duration: 3s;
            transition-duration: 3s;
            border: 2px solid rgb(255, 136, 0);
        }
        #delay {
            -webkit-transition-duration: 3s;
            -moz-transition-duration: 3s;
            -o-transition-duration: 3s;
            transition-duration: 3s;
            -webkit-transition-delay: 1s;
		    -moz-transition-delay: 1s;
		    -o-transition-delay: 1s;
		    transition-delay: 1s;
            border: 2px solid blue;
        }
    </style>
</head>
<body>
    <h3>νŠΉμ • μ‹œκ°„ 후에 νŠΈλžœμ§€μ…˜ μ‹€ν–‰ν•˜κΈ°</h3>
    <div id="trdelay">
        <div id="no-delay" class="box"><p>no-delay</p></div>
        <div id="delay" class="box"><p>delay</p></div>
    </div>
</body>
</html>

 

 


 

 

transition 속성 : νŠΈλžœμ§€μ…˜ 속성 ν•œκΊΌλ²ˆμ— ν‘œκΈ°

 

νŠΈλžœμ§€μ…˜ μ μš© λŒ€μƒμ΄ μ „체이고 νŠΈλžœμ§€μ…˜ μ‹€ν–‰ μ‹œκ°„이 λŒ€μƒλ³„λ‘œ λ‹€λ₯΄μ§€ μ•Šμ„ κ²½μš°μ—

ν•œκΊΌλ²ˆμ— 지정해 μ‚¬μš©ν•˜κΈ° νŽΈλ¦¬ν•œ μ†μ„±μœΌλ‘œ
λ‚˜μ—΄ μˆœμ„œλ§Œ μ œλŒ€λ‘œ μž…λ ₯ν•˜λ©΄ λœλ‹€.

 

 

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>transition</title>
    <style>
        .tr {
            width: 200px;
            height: 200px;
            background-color: red;
            border: 2px black solid;
            -webkit-transition: 2s ease-in;
            -moz-transition: 2s ease-in;
            -o-transition: 2s ease-in;
            transition: 2s ease-in;
            /* transition-property κΈ°λ³Έκ°’ all
            transition-duration κ°’ 2s
            transition-timing-function κ°’ ease-in
            transition-delay κΈ°λ³Έκ°’ 0*/
        }
        .tr:hover {
            width: 100px;
            height: 100px;
            background-color: pink;
            -webkit-transform: rotate(270deg);
            -moz-transform: rotate(270deg);
            -o-transform: rotate(270deg);
            -ms-transform: rotate(270deg);
            transform: rotate(270deg);
        }
    </style>
</head>
<body>
    <h3>transition 속성 ν•œκΊΌλ²ˆμ— ν‘œκΈ°ν•˜κΈ°</h3>
    <div class="tr"></div>
</body>
</html>

 

 


 

 

νŠΈλžœμ§€μ…˜μ—λ„ 접두사가 λ“€μ–΄κ°€λŠ” 것과

νŠΈλžœμŠ€νΌκ³ΌλŠ” λΉ„μŠ·ν•˜λ©΄μ„œλ„ ꡉμž₯히 λ‹€λ₯Έ λŠλ‚Œμ΄λΌ

잘 μ•Œκ³  μžˆμ–΄μ•Όκ² λ‹€.

 

 


 

 

< μ°Έκ³  >

Do it! HTML5+CSS3 μ›Ή ν‘œμ€€μ˜ 정석

 

 

β€» ν•΄λ‹Ή 글은 μŠ΅λ“ λͺ©μ μœΌλ‘œ μž‘μ„±λœ κΈ€μž…λ‹ˆλ‹€ β€»

 

λ°˜μ‘ν˜•

λŒ“κΈ€