简体   繁体   中英

How to set style for n-th td in a table using css

I have a table with 10 columns . How I can write css classes that set style for all TD s in 2 or 7 position ?

Something like:

tr td:nth-child(2), tr td:nth-child(7) {
    /* style here */
}

It's not supported in IE8 . But here's a very nice polyfill: ie9.js .

Alternatives:

  1. Use jQuery
  2. Add a custom class to each 2nd and 7th td

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM