Chillax in dev

[WEB]CSS: Hover 반응선택자 사용방법 본문

WEB

[WEB]CSS: Hover 반응선택자 사용방법

Seong Story 2020. 8. 8. 23:36
728x90

[CSS] Hover  반응 선택자 사용방법

- 자바스크립트 말고 CSS로 Hover 를 적용할 수 있습니다. 흔히들 호버라고 많이 사용하지만 정확한 명칭은 에이치 오버가 맞습니다. 

- 마우스가 해당 태그위에 있을 때와 벗어났을 때의 변화를 css로 줄 수 있습니다.

- 반응 선택자

 : 사용자의 반응으로 생성되는 특정한 상태를 선택하는 선택자.
- 종류
   1.  : hover ->  특정 태그에 마우스를 올릴 경우에 반응.
   2.  : active ->  특정 태그에 마우스를 클릭할 경우에 반응.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        #box01{background:yellow; width:400px; height: 50px; transition-duration:2s;}
    /*        transition-duration: 2s 2초에걸려서서히 변화주고싶어*/
        #box02{background:yellow; width:400px; height: 50px;transition-duration: 2s;}
        
        
        #box01:hover{background:blue; color: white;}
        #box02:hover{background:blue; color: white;}
        
        #box01:active{background: pink; height:800px;}
        #box02:active{background: pink; height:800px;}
/*        이옵션은 클릭(클릭후 유지)을 누른 동안에만 변경이된다.*/
        
        #box01:active+#box02{background: red; color:black;}
        #box02:active~#box03{background: green; color:red;}
        #ul03:hover{
         color: red;
         border-bottom:1px solid red;
         
        }
        
        
    </style>
</head>
<body>
<div id="third">
    <div id="third_view">
        <div id="third_view_left">
            <ul id="ul03">
                <li>&nbsp;홈&nbsp;</li>
                <li>현재상영/개봉예정</li>
                <li>박스오피스</li>
                <li>뉴스</li>
                
            </ul>
        </div>
        <div id="third_view_right">내평점</div>
    </div>
</div>
    <div id="box01">
        <h1>User Action Selector1</h1>
    </div>
    
    <div id="box02">
        <h1>User Action Selecto2r</h1>
    </div>
    <div id="box03">
        <h1>User Action Selector3</h1>
    </div>
</body>
</html>
cs
728x90
LIST
Comments