Change background color of background in iframe using single css file

Using iframe, where I call the site from my web space using a single css file with body {background-color: #222}.

Iframe src also uses this CSS file. The problem is that the body in the iframe needs a different background color.

tried to

iframe>body { background-color: #other }

Any idea or suggestions?

+3
source share
6 answers

I assume that iframe occupies a smaller part of your site. In this case, I would advise you to just use a div with the same iframe size and load that div into the corresponding background color.

OR: include the style property in the iframe page source:

<head>
    <style>body {background-color:#COLOR}</style>
</head>
+7
source

css iframe?. jQuery CSS iframe

$('#yourIframe').contents().find('body').css({
    background-color: '#333333'
});

Edit: , , iframe:

$('#yourIframe').load(function(){ 
    $(this).contents().find('body').css({
        background-color: '#333333'
    });
});
+5

, Javascript iframe , .

, .

+3

ive , . ( sooooo !)

CSS:

iframe {background-color: orange; }

"" , . !

!

+1

, iframe, , CSS, .

0

Javascript iframe

 var x = document.getElementById("myframe");
    var y = (x.contentWindow || x.contentDocument);
    if (y.document)y = y.document;
    y.body.style.backgroundColor = "red";

W3schools link

0
source

All Articles