Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any Fix for child selector in IE6

While using :first-child :last-child , in css its works fine in IE7, FF.

Is there any possible fix for this.

Use of Javascript is fine. If it works without javascript it would be great.

like image 903
Wasim Shaikh Avatar asked Dec 06 '22 06:12

Wasim Shaikh


2 Answers

You can use a semantic class name to ease your suffering in IE6. Something like:

  <ul>
    <li class="first">First Item</li>
    <li>Second Item</li>
    <li class="last">Last Item</li>
  </ul>

And then in your CSS use:

ul .first { color: #F00; }
ul .last { color: #00F; }
like image 133
noluckmurphy Avatar answered May 09 '23 07:05

noluckmurphy


Thanks all,

Here is the javascript version which I finally used for this Solutions.

  <script>

  $(document).ready(function(){
    $("ul li:last-child").addClass("last");
    $("ul li:first-child").addClass("first");

  });
  </script>
like image 22
Wasim Shaikh Avatar answered May 09 '23 05:05

Wasim Shaikh