Luca Frank Guarini
Luca Frank Guarini

Reputation: 1213

How to apply media query CSS rules to iframe content

I've got this set of code I would like to apply to my iframe, but it doesn't work.

@media only screen
and (min-width : 320px)
and (max-width : 480px) {
#postframe article{display:none;}
}

Thank you.

Upvotes: 3

Views: 21053

Answers (2)

Connor
Connor

Reputation: 1034

You could use javascript... maybe like this:

var cssLink = document.createElement("link");
cssLink.href = "yourStyle.css";  
cssLink.rel = "stylesheet";  
cssLink.type = "text/css";  
frames['yourFrame'].document.body.appendChild(cssLink);

Upvotes: 0

Luca Frank Guarini
Luca Frank Guarini

Reputation: 1213

Solved… My iframe width was 960px, so until you don't change width to 320px it could not recognize the media query!!

Thanks all

Upvotes: 9

Related Questions