是否有可能在伪元素之前/之后设置iframe样式? [英] Is it somehow possible to style an iframes before/after pseudo-element?
问题描述
正如标题所说,有没有办法在之后 / 之前设置iframes伪
的样式?没有用另一个
div
包装iframe,或者??
As the title says, is there a way to style an iframes pseudo before
/after
? Without wrapping the iframe with another div
, or else?`
我试着像任何其他元素一样设置样式,但没有成功:
I tried to style it like any other element, but no success:
iframe::before {
content: 'foo';
position: absolute;
top: 0;
left: 0;
}
iframe::after {
content: 'bar';
position: absolute;
top: 0;
right: 0;
}
http://fiddle.jshell.net/ppRqm/
更新
一个已知的解决方法是将前/后添加到源文件中的元素:
http://fiddle.jshell.net/ppRqm/2/
A known workaround is to add the before/after to an element in the source file: http://fiddle.jshell.net/ppRqm/2/
但有时你会无法访问源文件。
But sometimes you've no access to the source-file.
推荐答案
我不确定,但我认为这是不可能的。或者iframe背后的逻辑使其无法实现。
I am not sure but I think it isn't possible. Or the logic behind an iframe makes it imposible to achieve.
如您所知,伪元素 已添加到其容器,如果使用iframe执行此操作,则会在iframe中添加伪元素。
但是,问题是,如果浏览器不支持iframe,则会加载iframe内容内联内容。
As you know, pseudo-elements are added to its container, if you do that with an iframe, pseudo-elements would be added inside the iframe. But, and here's the problem, the iframe content, the inline content, will just load if the browser doesn't support iframes.
这意味着:
<iframe>
<div>Your browser doesn't support iframes</div>
</iframe>
添加伪元素会做同样的事情;在现代浏览器上内联内容 将无法显示。
And adding pseudo-elements, will do the same thing; on modern browsers inline content wouldn't be displayed.
这篇关于是否有可能在伪元素之前/之后设置iframe样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!