如何将css样式应用到iframe内容中? [英] How to applying css style into an iframe content?
本文介绍了如何将css样式应用到iframe内容中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想对iframe中的内容应用CSS样式,请检查此链接 http://jsfiddle.net/pPqGe/
I am trying to apply a CSS style for content inside the iframe, please check this link http://jsfiddle.net/pPqGe/
jQuery:
$(document).ready(function() {
$('iframe').contents().find('h1').css('color','red');
});
HTML:
<iframe src="mysite" width="100%" height="100%" id="myframe"></iframe>
对于iframe源我使用了一个现场网站。
For iframe source I have used a live website.
推荐答案
它工作。问题是没有H1,只有H2。
查看此链接 http://jsfiddle.net/pPqGe/1545/ 。
It works. Problem is there is no H1, only H2. Check out this link http://jsfiddle.net/pPqGe/1545/.
HTML:
<iframe src='jsfiddle.net'></iframe>
JavaScript:
JavaScript:
$(document).ready(function() {
$('iframe').contents().find('h2').css('color','red');
$('iframe').contents().find('#header').css('opacity','.2');
});
这篇关于如何将css样式应用到iframe内容中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文