如何让这个iframe丢失边框/滚动条并调整大小以适应DIV?

时间:2011-02-13 22:28:57

标签: iframe html

我已经尝试过其他人说过的话,但似乎没有用。你可以自己编码吗?我真的很沮丧。

<a href="#computing" onclick="document.getElementById('MainBack').innerHTML = '<iframe src=\'test.html\'></iframe>'">Computing</a>

这是我想要的地方:

http://markbrewerton.co.uk/work.html#computing

2 个答案:

答案 0 :(得分:0)

使用像这样的CSS规则使iframe填充它的父级并且没有边框:

#MainBack iframe { width: 100%; height: 100%; border: none; }

Internet Explorer不尊重border设置,因此您还需要在代码中设置frameborder属性:

<a href="#computing" onclick="document.getElementById('MainBack').innerHTML = '<iframe src=&quot;test.html&quot; frameborder=&quot;0&quot;></iframe>'">Computing</a>

答案 1 :(得分:0)

HTML

<iframe src="" scrolling="no" frameborder="0" allowtransparency="true"></iframe>

CSS

border:none;
overflow:hidden;
width:450px;
height:35px;"

在IE中使用Allowtransparecy,否则你会看到与页面背景不同的背景。

编辑: 添加了转义版本

<a href="#computing" onclick="document.getElementById('MainBack').innerHTML = '<iframe src=\'http://www.google.com\'  scrolling=\'no\' frameborder=\'0\' allowtransparency=\'true\'></iframe>'">Computing</a>    
<div id="MainBack"></div>