IE7 中对 :after 的支持

发布于 2024-12-27 10:57:24 字数 712 浏览 3 评论 0原文

长话短说,我想在另一个元素之后添加一个绝对定位的伪元素,因此我只需在样式表中使用 :after 伪元素。除了在 IE7 中之外,这就像一个魅力。我认为 IE7 应该支持 :after ,不是吗? Boilerplate 中使用的 clearfix hack 效果很好,那么为什么不在我的示例中呢?

当我在样式检查器中查看 CSS 时,它似乎确实将其打印出来,因此在我看来它可以理解它,但我仍然看不到生成的元素。我错过了什么吗?

.myclass:after { 
   content:"";
   display:table;
   width:100px;
   height:100px;
   background:#f7f7f7;
   position:absolute;
   top:0;
   left:-1px;
   z-index:0; }
.myclass > div {
   position:relative;
   z-index:10; }   
.myclass { 
   z-index:1;
   position:relative; }

这是一个小提琴

Long story short, I want to add an absolutely positioned pseudo element after another element, so I simply use the :after pseudo element in my stylesheet. This works like a charm, except in IE7. I should think that :after is supported in IE7, no? The clearfix hack used in Boilerplate works fine, so why not in my example?

When I look at the CSS in the style inspector, it does seem to print it out, so it seems to me that it understands it, but I can't see the generated element nonetheless. Am I missing something?

.myclass:after { 
   content:"";
   display:table;
   width:100px;
   height:100px;
   background:#f7f7f7;
   position:absolute;
   top:0;
   left:-1px;
   z-index:0; }
.myclass > div {
   position:relative;
   z-index:10; }   
.myclass { 
   z-index:1;
   position:relative; }

Here's a Fiddle!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜`诱少女 2025-01-03 10:57:24

不支持 :before:after 在 IE7 中,您还可以使用其他选项,例如 IE8.js

There is no support for :before and :after in IE7, there are other options that you can use like IE8.js.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文