Is there a fix for child selector in IE6

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

Is there a possible fix for this.

Using javascript is fine. If this works without javascript, it would be great.

+4
source share
4 answers

Thanks everyone

Here is the javascript version that I finally used for these Solutions.

<script> $(document).ready(function(){ $("ul li:last-child").addClass("last"); $("ul li:first-child").addClass("first"); }); </script> 
+3
source

You can use the semantic class name to ease your suffering in IE6. Sort of:

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

And then in your use of CSS:

 ul .first { color: #F00; } ul .last { color: #00F; } 
+10
source

There is an exact solution that does not require changes to your HTML. Use Microsoft Dynamic Styles. Here is an example:

 <html> <head> <style type="text/css"> tr td:first-child {font-weight:bold; background-color:green;} tr td:last-child {background-color:orange;} tr td {_font-weight:expression(this.previousSibling==null?'bold':'normal'); _background-color:expression(this.previousSibling==null?'lightgreen':(this.nextSibling==null?'orange':''));} </style> </head> <body> <table> <tr><td>First</td><td>Second</td><td>Third</td><td>Last</td></tr> <tr><td>First</td><td>Second</td><td>Third</td><td>Last</td></tr> <tr><td>First</td><td>Second</td><td>Third</td><td>Last</td></tr> </body> </html> 

Also see http://mauzon.com/pseudoclasses-first-child-and-last-child-for-ie6/ .

+3
source

A more general library that captures a bunch of IE inconsistencies is IE7 Dean Edwards: http://dean.edwards.name/IE7/

0
source

Source: https://habr.com/ru/post/1286091/


All Articles