소스


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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<html>
<head>
    <meta>
    <style>
        table{
            width: 100%;
        }
        tr:first-child{
            background-color: darkgray;
        }
        tr:nth-child(2n){    /*짝수*/
            background-color: beige;
        }
        tr>th:nth-child(1){
            width: 10%;
        }
        tr>th:nth-child(2){
            width: 60%;
        }
        tr>th:nth-child(3){
            width: 20%;
        }
        td>a{
            display: inline-block;
            width: 100%;
            text-decoration: none;
            color: black;
        }
        .line:hover{
            background-color: darksalmon;
        }
    </style>
</head>
<body>
    <table>
        <tr>
            <th>1열</th>
            <th>2열</th>
            <th>3열</th>
            <th>4열</th>
        </tr>
        <tr class="line">
            <td><a href="#">1줄</a></td>
            <td><a href="#">1</a></td>
            <td><a href="#">2</a></td>
            <td><a href="#">3</a></td>
        </tr>
        <tr class="line">
            <td>2줄</td>
            <td>1</td>
            <td>2</td>
            <td>3</td>
        </tr>
        <tr class="line">
            <td>3줄</td>
            <td>1</td>
            <td>2</td>
            <td>3</td>
        </tr>
        <tr class="line">
            <td>4줄</td>
            <td>1</td>
            <td>2</td>
            <td>3</td>
        </tr>
        <tr class="line">
            <td>5줄</td>
            <td>1</td>
            <td>2</td>
            <td>3</td>
        </tr>
        <tr class="line">
            <td>6줄</td>
            <td>1</td>
            <td>2</td>
            <td>3</td>
        </tr>
        <tr class="line">
            <td>7줄</td>
            <td>1</td>
            <td>2</td>
            <td>3</td>
        </tr>
        <tr class="line">
            <td>8줄</td>
            <td>1</td>
            <td>2</td>
            <td>3</td>
        </tr>
        <tr class="line">
            <td>9줄</td>
            <td>1</td>
            <td>2</td>
            <td>3</td>
        </tr>
    </table>
</body>
</html>
cs


결과

마우스를 올리고 있는 경우


소스


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
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <style>
        *{
            padding: 0px;
            margin: 0px;
        }
        div{
            width: 100px;
            height: 100px;
        }
        /*띄어쓰기는 자식을 포함한 모든 자식들에게 적용 / 콤마는(,) 자신까지 */
        body div{
            border-bottom-color: black;
            border-width: 1px;
            border-style: solid;
        }
        body>div>div{
            width: 50px;
            height: 50px;
            background-color: antiquewhite;
        }
        body>div>div>div{
            width: 30px;
            height: 30px;
            background-color: aquamarine;
        }
        /*차이점 확인하기 첫번째 자식한테만 해당*/
        body>div>div:first-child{
            background-color: blueviolet;
        }
        body>div:last-child{
            background-color: fuchsia;
        }
        
    </style>
</head>
<body>
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>
        <div>4</div>
    </div>
    <div>  
        <div>
            <div>5</div>
        </div>
    </div>
    
</body>
</html>
cs


결과



* 우선순위 알기

우선순위가 높은 것 부터 나열

 인라인(<div style=""> : 사용하지않는게 좋다) > id(#) > 선택자(:) > class(.) > 태그지시자 ( 우선순위가 같다면 오버라이드 )


+ Recent posts