CSS / HTML5等同于iframe marginheight和marginwidth [英] CSS/HTML5 equivilent to iframe marginheight and marginwidth

查看:453
本文介绍了CSS / HTML5等同于iframe marginheight和marginwidth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为使用IDevAdManager在其网站上轮播广告的公司制作了网站布局。不幸的是,我不是那个领域的专家,所以我不能给予太多。我可以肯定地说,由于生成器的性质,生成的iframe里面的源不能被我编辑。

I am doing a website layout for a company who uses IDevAdManager for rotating ads on their site. Unfortunately, I am not much of an expert in that field, so I can't give much on that. What I can say for sure though, due to the nature of the generator, the source inside the iframes it generates are not editable by me.

现在,这里是我的问题。

Now, here is my problem.

我想让他们的新网站符合HTML5,但我遇到了一个有趣的问题。

I am trying to make their new website HTML5 compliant, but I have reached an interesting issue.

当涉及到从广告轮换器添加iframe时,它生成所有以前的HTML实现使用的旧的,折旧的标签。

When it comes to adding the iframes from the ad rotator, it generates all of the old, depreciated tags used by previous implementations of HTML.

显然,大部分是可移动的与CSS。除了marginheight和marginwidth属性。

Obviously, most of this is removable with CSS. All except, however, for the marginheight and marginwidth attributes.

这是我到达我的问题的地方。似乎没有一个CSS相当于marginheight或边距宽度,并且没有办法访问iframe中的源。

Here is where I reach my problem. There does not seem to be a CSS equivalent to either marginheight or margin width, and there is no way to access the source within the iframes. However, leaving them out prevents the inner content from lining up properly.

我希望找到一个既是有效的HTML5解决方案,也解决了我的问题。

I am hoping to find a solution that is both valid HTML5, and solves my problem.

这样的选项目前是否存在?

Does such an option currently exist? Or will I have to use the deprecated tags until a solution is designed?

推荐答案

实际上这是一个有效的问题。不幸的是,marginheight,marginwidth和frameborder是iframe元素本身的属性,而不是元素的style属性参见 http://www.w3schools.com/jsref/prop_frame_marginheight.asp

Actually this is a valid question. Unfortunately it turns out that the marginheight, marginwidth and frameborder are properties of the iframe element itself, not the element's style property see http://www.w3schools.com/jsref/prop_frame_marginheight.asp

例如,您可以在JavaScript中执行此操作: -

So, for example, you can do this in JavaScript:-

document.getElementById("SomeIframe").marginheight = "0";

但您不能这样做

document.getElementById("SomeIframe").style.marginheight = "0";

并且设置边距没有效果(即,您仍然会在iframe元素中获得默认边距) : -

and setting the margin has NO EFFECT (i.e. you will still get the default margin in the iframe element):-

document.getElementById("SomeIframe").style.margin = "0";

所以cbright6062的问题的答案是没有办法设置marginheight,marginwidth和frameborder属性的样式表中的iframe。

So the answer to cbright6062's question is that there is no way to set the marginheight, marginwidth and frameborder properties of an iframe in a style sheet.

这篇关于CSS / HTML5等同于iframe marginheight和marginwidth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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