在iFrame中应用CSS [英] Applying CSS within an iFrame

查看:151
本文介绍了在iFrame中应用CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将广告图片的宽度从像素更改为百分比。我使用的是Google DoubleClick或DFP。它会自动将您的广告图片放在iframe中,这很难更改图片的实际尺寸。

I'm trying to change the width of my ad image from pixels to percentages. I'm using Google DoubleClick or "DFP". It automatically puts your ad image inside an iframe, making it very hard to change the actual dimensions of the image.

所以,我改变图片的方式宽度从像素到百分比是,我做了一个div(即90%的网页)包围图像广告,然后设置图像的宽度为100%,所以当包装器宽度改变浏览器宽度调整大小,其内的图像总是填满包装。但我不知道如何使这一切都工作,因为图像是在一个iframe(愚蠢的DFP !!!)

So, the way I've gone about changing the images width from pixels to percentage is, I made a div (that is 90% of the webpage) wrapped around the image ad and then set the image's width to 100% so when the wrappers width changes on browser width resize, the image within it will always fill up the wrapper. But I don't know how to make this all work since the image is within an iframe (stupid DFP!!!)

这里是CSS代码为...包装器:

Here is the CSS codes for... the wrapper:

#div-gpt-ad-1362958263281-0 {width:90%; border:1px solid black;}

然后是包装器中的iframe:

then the iframe which is in the wrapper:

iframe {width:100%;}


b $ b

然后最终的实际图像,其中我尝试了几个CSS选择器和不同的div类:

then finally the actual image in which i tried a few CSS selectors and different div classes:

.img_ad, a#aw0, iframe>.img_ad, iframe>#google_image_div>.img_ad {width:100%; display:block; border:1px solid red !important;}



如果在Google图片上检查Google Chrome中的元素,您将看到CSS未应用于图像。所有我想要做的是将图像宽度更改为百分比..以及高度 auto 。应该真的是这么难吗?这是甚至可能的,因为图像是在iframe? DFP是否将我设置为失败?我只是不知道...但是,我如何改变图像广告的代码?任何帮助真正真正真正地赞赏的家伙! :)

If you inspect element in Google Chrome on the ad image, you will see that the CSS isn't being applied to the image. All I'd like to do is change the images width into a percentage.. and also the height to auto. Should it really be this hard? Is this even possible since the image is in an iframe? Is DFP setting me up for failure? I just don't know... But, how would I alter the image ad's code? Any help would truly truly truly be appreciated guys! :)

这里是jsFiddle:
http://jsfiddle.net/EptwH/3/

Here is the jsFiddle: http://jsfiddle.net/EptwH/3/

推荐答案

iframe 这里是在不同的域。您无法使用CSS或JS修改其内容。

The iframe here is on a different domain. You can't modify it's contents with CSS or JS.

这篇关于在iFrame中应用CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆