CSS: IE7 First Parent Selector
1 answer
If the first child [class*="span"]
, check if there is an HTML comment in front of it. If so, IE7 will mistakenly think the comment is the first child , so it won't match the element you're looking for.
If you cannot change the markup to remove the comment, you can work around this by using the override method I describe here :
.row [class*="span"] {
margin-left: 0;
}
.row [class*="span"] ~ [class*="span"] {
margin-left: /* Reset the left margin for other elements */;
}
If you don't know the value of the field before reset, you can try adding another selector that targets IE7's behavior with a * + html
hack:
.row [class*="span"]:first-child, * + html .row :first-child + [class*="span"] {
margin-left: 0;
}
:first-child + [class*="span"]
matches this element if it matches exactly one comment node, which is the first child in IE7.
+6
source to share