Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it somehow possible to style an iframes before/after pseudo-element?

Tags:

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/

Update

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.

like image 231
yckart Avatar asked Jun 05 '13 14:06

yckart


People also ask

Can you style IFrames?

Styling the contents of an iframe is just like styling any other web page. But, you must have access to edit the page. If you can't edit the page (for example, it's on another site).

What can you do with the before pseudo element?

The ::before pseudo-element can be used to insert some content before the content of an element.

Can I have multiple before pseudo elements for the same element?

In CSS2. 1, an element can only have at most one of any kind of pseudo-element at any time. (This means an element can have both a :before and an :after pseudo-element — it just cannot have more than one of each kind.)

What is the correct syntax for styling before pseudo element?

In CSS, ::before creates a pseudo-element that is the first child of the selected element. It is often used to add cosmetic content to an element with the content property. It is inline by default.


1 Answers

I am not sure but I think it isn't possible. Or the logic behind an iframe makes it imposible to achieve.

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.

This means that this:

<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.

like image 81
pzin Avatar answered Sep 21 '22 18:09

pzin