Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
384 views
in Technique[技术] by (71.8m points)

html - Make alternating CSS table row style work in Internet Explorer

I use this CSS code to display a database output in rows where the colors repeat in every 2nd row

tbody tr:nth-child(2n) td, tbody tr.even td {  
    background: none repeat scroll 0 0 #E5ECF9;  
}

If I open it in my IE it won't work. Any advice?

I am using IE 8.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

IE8 does not support the :nth-child CSS property. You can make it work in IE8 with this script:

https://github.com/roylory/ie7-js

How to use it:

You can Include it via conditional comments, e.g.:

<!--[if lte IE 9]>
<script src="IE9.js"></script>
<![endif]-->

The script will only load in IE9 and below, other browsers do not see it.

Live demo: https://jsbin.com/koyahe/edit?html,css,output

(This demo should work in all versions of IE.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...