컴

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

· 2017-03-09 (목) 23:37:25 · 1909

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>

789de082eda191a16b29225dae1ca3ac_1489070202_4992.png

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

퍼블리셔팁

1,282건

퍼블리싱과 관련된 유용한 정보를 공유하세요. 질문은 상단의 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
CSS 17-03-13 조회 2,874
CSS 17-03-13 조회 2,752
CSS 17-03-11 조회 2,219
CSS 17-03-11 조회 2,249
CSS 17-03-11 조회 2,485
CSS 17-03-09 조회 1,910
CSS 17-03-09 조회 2,552
CSS 17-03-09 조회 2,094
CSS 17-03-08 조회 2,527
CSS 17-03-08 조회 2,585
CSS 17-03-08 조회 2,573
CSS 17-02-28 조회 2,385
CSS 17-02-28 조회 2,119
CSS 17-02-28 조회 2,595
CSS 17-02-27 조회 1,925
CSS 17-02-27 조회 2,027
CSS 17-02-27 조회 2,135
CSS 17-02-26 조회 2,750
CSS 17-02-26 조회 2,821
CSS 17-02-26 조회 2,196
CSS 17-02-25 조회 2,658
CSS 17-02-25 조회 2,224
CSS 17-02-25 조회 2,263
CSS 17-02-24 조회 2,169
CSS 17-02-24 조회 1,883
CSS 17-02-24 조회 1,934
CSS 17-02-21 조회 3,455
CSS 17-02-21 조회 2,454
CSS 17-02-21 조회 2,056
CSS 17-02-20 조회 2,485