css选择器IE6,7修复

css selectors IE6,7 fix

本文关键字:修复 IE6 选择器 css      更新时间:2023-09-26

有什么方法可以在IE6,7中模拟css选择器"+"吗?

h1 + h2{margin-top: 10px;}

找不到任何解决方案。

您可以使用jQuery为IE6:添加类

<script>
$('H1 + H2').addClass('h2-after-h1');
<script>
<style>
.h2-after-h1 {margin-top: 10px; }
<style>

在IE7中,相邻的同级组合子(+)在与HTML注释相关的错误所造成的限制下,可以本地工作。有一种JavaScript解决方法,可以在加载页面后删除作为DOM节点的HTML注释。