문제

Is it possible to apply a style to a column? for example lets say I want the 2nd column to be red (in reality it'd be more complicated). Below/this demo I gave the 2nd column the class b but I have no idea how to make the 2nd column of every row red. I only know how to style the header

.b { color: red; }

<table>
    <th>a</th>
    <th class="b">b</th>
    <th>a</th>
    <tbody>
        <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        </tr>
        <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        </tr>
        <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        </tr>
        <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        </tr>
    </tbody>
</table>
도움이 되었습니까?

해결책

http://jsfiddle.net/EEJfc/3/

Use nth-child selector.

In your case

table td:nth-child(2) { color: red }

다른 팁

Use nth-child

tbody tr td:nth-child(2){color: red;}

Demo JsFiddle

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top