Styles for CSS classes in iframe

Inspired by the new User Flair , but the question applies to the general business as well.

Let's say I want to include something like this on a site that prevents me from specifying external styles or using any JavaScript code. The only thing I can do is insert object

, embed

or iframe

some other simple HTML. Also, the space width is only 160 pixels, not the default 200 required for the diff icon.

To fix this, I want to set styles for the class valuable-flair

in the iframe, namely change the width like 160px

instead 200px

. Then everything will be fine as long as the username doesn't overlap (and even when I figure it out, I can use the same method to play with it).

How can this be done?

+1


a source to share


2 answers


There is no way to change the design of an iframe with CSS if you cannot control the page in the SRC attribute.

I recommend you read src iframe server side (using PHP, Python or whatever you like) eg. fopen () src and fread () to a variable than any str_replace for that variable (to fetch content, remove <body>, </body> ...) play with the design and put the result in your page.



This way you can control the design.

+1


a source


If the CSS for width and height were expressed as percentages rather than absolute values, you can adjust the width by adjusting the IFrame. However, if hosting a custom implementation isn't possible for you, you're out of luck without JavaScript.



0


a source







All Articles