IE8 不打印 :before 伪元素中的图像
我想在文本之前放置一个图标图像。任何 HTML 标签,例如 应避免,因为 HTML 结构的任何更改都可能影响我们的 javascript 代码。
我编写了以下代码,它可以在 IE8/Firefox 的屏幕上运行。
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv='X-UA-Compatible' content='IE=8' />
<style type="text/css">
div.before-test:before {
content: url("sample.png");
}
</style>
</head>
<body>
<div>aaaa</div>
<div>bbbb</div>
<div class="before-test">cccc</div>
<div>dddd</div>
</body>
</html>
但是,当访问者尝试使用 IE8 打印网页时,图像消失了。即使使用 IE8 打印,如何才能显示图像,还是必须为图像添加 HTML 标签?
I want to put an icon image before a text. Any HTML tag such as <img> should be avoided because any changes of HTML structure may affect our javascript code.
I write the following code and it works on screen with IE8/Firefox.
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv='X-UA-Compatible' content='IE=8' />
<style type="text/css">
div.before-test:before {
content: url("sample.png");
}
</style>
</head>
<body>
<div>aaaa</div>
<div>bbbb</div>
<div class="before-test">cccc</div>
<div>dddd</div>
</body>
</html>
But, when visitors try to print the web page with IE8, the image disappears. How can I show the image even when printing with IE8, or must I add HTML tag for the image?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
IE8之前支持,但兼容模式下不支持。
IE8 supports before but not in compatibility mode.
我认为您应该查看本指南,了解某些浏览器(尤其是 IE 6 及更高版本)支持哪些属性和内容。
http://www.quirksmode.org/css/contents.html
顺便说一下,
url()
中的 url - 引号是可选的。最好没有,以避免不必要的转义问题http://www. w3.org/TR/CSS2/syndata.html#value-def-uri
i think you should look at this guide as to what properties and stuff are supported on some browsers especially IE 6 and up.
http://www.quirksmode.org/css/contents.html
by the way, the url in
url()
- quotes are optional. better to have none to avoid unnecessary escaping issueshttp://www.w3.org/TR/CSS2/syndata.html#value-def-uri
我能找到的唯一方法是来自 stackoverflow。 没有解决方案
我知道,这不是一个好方法,但是,我想这个错误HTML:
CSS:
The only way i could find is from in stackoverflow. I know, it is not a good approach but , i guess there is no solution about this bug
HTML:
CSS: