본문 바로가기

HTML&CSS

CSS로 <table>꾸미기

 

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 lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table{
            border-collapse: collapse; /*이중테두리 제거*/
        }
        td,th{
            text-align: left;
            padding: 5px;
            height: 15px;
            width: 100px;
        }
        thead,tfoot{
            background-color: darkgray;
            color:yellow;
        }
        tbody tr:nth-child(even){ /*짝수(even)에만 적용, 홀수(odd)*/
            background-color: aliceblue;
        }
        tbody tr:hover {
            background-color: pink;
            }
    </style>
</head>
<body>
    <h3>1학기 성적</h3><hr>
    <table>
        <thead>
            <tr>
                <th>이름</th> <!--th태그는 center, bold 효과 포함되어 있음.-->
                <td>HTML</td>
                <td>CSS</td>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th></th> <!--th태그는 center, bold 효과 포함되어 있음.-->
                <td>310</td>
                <td>249</td>
            </tr>
        </tfoot>
        <tbody>
        <tr><td>황기태</td><td>80</td><td>70</td></tr>
        <tr><td>이재문</td><td>95</td><td>99</td></tr>    
        <tr><td>이병은</td><td>85</td><td>90</td></tr>
        <tr><td>김남윤</td><td>50</td><td>40</td></tr>
        </tbody>
    </table>
</body>
</html>
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs

'HTML&CSS' 카테고리의 다른 글

flex grow  (0) 2020.07.01
배치 position 속성 static, relative, absolute, fixed  (0) 2020.06.22
CSS로 <form>  (0) 2020.03.06
CSS를 <li>에 적용해 메뉴 만들기 // To create menu  (0) 2020.03.06
CSS 마우스 커서 // cursor  (0) 2020.03.06