태그 보관물: html-table

html-table

첫 번째 행의 셀에 스타일 적용 1</td><td> blabla 2 </td></tr>

매우 간단해야하지만 알아낼 수 없습니다.

다음과 같은 테이블이 있습니다.

<table class="category_table">
 <tr><td> blabla 1</td><td> blabla 2 </td></tr>
 <tr><td> blabla 3 </td><td> blabla 4 </td></tr>
</table>

내가 만들고 싶어 td최초의 태그 tr행이 있습니다 vertical-align. 그러나 두 번째 줄은 아닙니다.

.category_table td{
    vertical-align:top;
}


답변

사용 tr:first-child하여 첫 번째 tr:

.category_table tr:first-child td {
    vertical-align: top;
}

중첩 테이블이 있고 내부 행에 스타일을 적용하지 않으려면 td첫 번째 최상위 수준 의 최상위 수준 tr만 스타일을 가져 오도록 일부 자식 선택기를 추가 합니다.

.category_table > tbody > tr:first-child > td {
    vertical-align: top;
}

답변

이 작업을 수행해야합니다.

.category_table tr:first-child td {
    vertical-align: top;
}

답변

아래 tr표의 첫 번째 작업은 다음 과 같습니다.thead

table thead tr:first-child {
   background: #f2f2f2;
}

그리고 이것은 처음 작동 trtheadtbody모두 :

table thead tbody tr:first-child {
   background: #f2f2f2;
}

답변