IE8 :nth-child and :before Compatibility Issue
Internet Explorer 8 presents challenges when working with CSS selectors such as :nth-child and :before. While these selectors function effectively in most other browsers, IE8 encounters compatibility issues.
The Question
In an attempt to target specific navigation links in CSS, a developer encountered a problem with :nth-child and :before in IE8. While setting properties for the :nth-child(1) selector applied to a specific link, the same properties failed to work when applied to the :after pseudo-element.
The Answer
While :nth-child is not directly supported in IE8, there is a workaround involving the adjacent sibling combinator ( ). By utilizing this method, you can target specific items in a list:
Limitations
While this workaround replicates basic :nth-child functionality, it has its limitations. Emulating more complex variants (e.g., :nth-child(odd) or :nth-child(4n 3)) is not possible with this method.
The above is the detailed content of Why Can't I Use `:nth-child` and `:before` in IE8?. For more information, please follow other related articles on the PHP Chinese website!