πŸ“

13. Hover, Active, Focus

Β 
Β 

μƒν˜Έ μž‘μš©μ„ μœ„ν•œ κ°€μƒν΄λž˜μŠ€

:hover

μ‚¬μš©μžκ°€ 마우슀λ₯Ό μš”μ†Œ μœ„μ— μ˜¬λ Έμ„ λ•Œ μ μš©λ©λ‹ˆλ‹€. μŠ€λ§ˆνŠΈν°μ΄λ‚˜ νŒ¨λ“œ λ₯˜μ˜ ν„°μΉ˜μŠ€ν¬λ¦° κΈ°κΈ°μ—μ„œλŠ” μ‚¬μš©μžμ˜ 손가락이 ν˜Έλ²„λ˜λŠ” μ‹œμ μ„ μ•Œ 수 μ—†κΈ° λ•Œλ¬Έμ— λͺ¨λ°”일 κΈ°κΈ°κ°€ λ§Žμ•„μ§€λ©΄μ„œ 점점 μ‚¬μš© λΉˆλ„κ°€ μ€„μ–΄λ“œλŠ” κΈ°λŠ₯μž…λ‹ˆλ‹€.

:active

μ‚¬μš©μžκ°€ μš”μ†Œλ₯Ό μ‹€ν–‰ν•  λ•Œ(λ²„νŠΌμ„ λˆ„λ₯΄κ±°λ‚˜ 링크λ₯Ό 클릭할 λ•Œ) μ μš©λ©λ‹ˆλ‹€.

:focus

μš”μ†Œμ— ν¬μ»€μŠ€κ°€ μžˆμ„ λ•Œ μ μš©λ©λ‹ˆλ‹€. 클릭할 수 μžˆλŠ” μš”μ†Œλ‚˜ 폼컨트둀(input, select λ“±λ“±)κ³Ό 같이 μƒν˜Έμž‘μš© ν•  수 μžˆλŠ” λͺ¨λ“  μš”μ†Œμ—λŠ” ν¬μ»€μŠ€κ°€ κ°€λŠ₯ν•©λ‹ˆλ‹€.
Β 
<!DOCTYPE html> <html lang="ko"> <head> <title>λ²„νŠΌ</title> <style> .btn { border: 4px solid palevioletred; border-radius: 4px; padding: 30px 60px; background: none; color: palevioletred; font-size: 32px; position: relative; overflow: hidden; cursor: pointer; transition: all .3s; } .btn:hover { color: white; border: 4px solid firebrick; } .btn:before { content: ""; position: absolute; bottom: 0; left: 0; width: 100%; height: 100%; background: palevioletred; z-index: -1; border-radius: 100px 100px 0px 0px; height: 0px; transition: all .3s; } .btn:hover:before { height: 120px; background: firebrick; } .btn:active { background-color:#000; } .box { border:1px solid palevioletred; display:block; height:40px; margin-bottom:10px; padding:0 5px; } .box:focus { background-color:rgba(0,0,255,0.1); } .box:focus::placeholder { color:red; font-weight:600; } </style> </head> <body> <input type="text" class="box" placeholder="Click Here!"> <button class="btn">Click Me!!</button> </body> </html>
Β 
μ’€ 더 λ‹¨μˆœν•œ 예제
<!DOCTYPE html> <html lang="ko"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>hover, active, focus</title> <style> .one { background: blueviolet; width: 100px; height: 100px; transition: all 2s; } .one:hover { background:crimson; width: 200px; height: 200px; } .btn { border: 4px solid palevioletred; border-radius: 4px; padding: 30px 60px; background: none; color: palevioletred; font-size: 32px; transition: all .3s; } .btn:active { background-color: purple; color:white; } .box { transition: all .3s; } .box:focus { background: red; color: white; } </style> </head> <body> <div class="one"></div> <input type="text" class="box" placeholder="click here!"> <button class="btn">Click Me!!</button> </body> </html>