:之后和:之前css伪元素攻击IE 7

Soa*_*abh 57 html css internet-explorer-7 pseudo-element

我正在使用:after:beforecss伪元素,它在IE8和所有现代浏览器中工作正常,但它在IE7中工作不正常.在IE7中有没有可以解决这个问题?

Jit*_*yas 68

任何纯CSS攻击都是不可能的.

使用IE8.js http://code.google.com/p/ie7-js/

它支持这一点.http://ie7-js.googlecode.com/svn/test/index.html

测试页面也在那里

之后 - http://ie7-js.googlecode.com/svn/test/after.html

之前 - http://ie7-js.googlecode.com/svn/test/before.html

在第一条评论后编辑

您可以为IE6和7保留此js.其他浏览器将无法读取它.

<!--[if lt IE 8]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE8.js"></script>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)

如果你已经在项目中使用jQuery,那么你可以使用这个插件

jQuery Pseudo Plugin

http://jquery.lukelutman.com/plugins/pseudo/


vie*_*ron 52

我在一个项目中使用IE8.js(http://code.google.com/p/ie7-js/)并且我不得不将其删除,因为它在10/15秒之间阻止了IE7.

要保留使用以下内容生成的内容:after和:之前的伪元素,不使用IE8.js,我执行了以下操作:

   .tabs {
     *zoom: expression( 
          this.runtimeStyle.zoom="1",
          this.appendChild( document.createElement("small") ).className="after"
         );
   }

   .tabs:after,
   .tabs .after {
     content: '';
     display:block;
     height:10px;
     width:100%;
     background:red;
   }
Run Code Online (Sandbox Code Playgroud)

我喜欢这种方式,而不是使用javascript,因为这将使所有选择器保持在同一个地方:)

  • 这是使用JavaScript执行的,只是为了清楚. (7认同)