테스트 사이트 - 개발 중인 베타 버전입니다

Striped Tables(스트라이프 테이블)

· 8년 전 · 1544

Striped Tables(스트라이프 테이블)

 

First Name Last Name Savings

Peter Griffin $100

Lois Griffin $150

Joe Swanson $300

For zebra-striped tables, use the nth-child() selector and add a background-color to all even (or odd) table rows:

 

Example

tr:nth-child(even) {background-color: #f2f2f2}

 

<!DOCTYPE html>

<html>

<head>

<style>

table {

    border-collapse: collapse;

    width: 100%;

}

 

th, td {

    text-align: left;

    padding: 8px;

}

 

tr:nth-child(even){background-color: #f2f2f2}

</style>

</head>

<body>

 

<h2>Striped Table</h2>

<p>For zebra-striped tables, use the nth-child() selector and add a background-color to all even (or odd) table rows:</p>

 

<table>

  <tr>

    <th>First Name</th>

    <th>Last Name</th>

    <th>Points</th>

  </tr>

  <tr>

    <td>Peter</td>

    <td>Griffin</td>

    <td>$100</td>

  </tr>

  <tr>

    <td>Lois</td>

    <td>Griffin</td>

    <td>$150</td>

  </tr>

  <tr>

    <td>Joe</td>

    <td>Swanson</td>

    <td>$300</td>

  </tr>

  <tr>

    <td>Cleveland</td>

    <td>Brown</td>

    <td>$250</td>

  </tr>

</table>

 

</body>

</html>



댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시글 목록

번호 제목
3133
3132
3131
3130
3129
3128
3127
3121
3120
3112
3111
3110
3109
3108
3107
3105
3104
3103
3101
3100
3099
3098
3097
3096
3094
3093
3092
3090
3089
3088