What is the replacement for the child selector?

后端 未结 8 874
庸人自扰
庸人自扰 2021-02-06 02:57

Since IE6 does not support the child selector (see http://kimblim.dk/csstest/#ex1), what is the alternative when dealing with this browser?

I do not want to modify the m

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-06 03:48

    You can use jQuery, not a pretty solution, but it is one option that I have used in the past:

    $("parent > child").each(function() {
        $(this).addClass("child-styles");
    }
    

    You are obviously going to want to wrap this in some specialized IE6 only check. And probably want a style sheet wrapped in the IE6 IF statement to add these specialized styles.

提交回复
热议问题