2015-01-14 110 views
5

小提琴(这是我的实际代码的骨架):http://jsfiddle.net/nkipe/6bhee8c8/
代码:
CSS如何摆脱恼人的iframe边框?

* 
{ 
    -webkit-box-sizing: border-box; 
    -moz-box-sizing: border-box; 
    box-sizing: border-box; 
    margin: 0; padding: 0; 
} 
html 
{ 
    height: 100%; 
} 
body 
{ 
    height: 100%; 
    background: #FEFFFB; 
    font-family: arial, verdana; 
} 
#layoutContainer 
{ 
    width: 100%; 
    height: 100%; 
    top: 0px; 
    left: 0px; 
    position: fixed; 
} 

#iframeHeader 
{ 
    width: 100%; 
    height: 50px; 
    border: 0; 
} 
#iframeStatusBar 
{ 
    width: 100%; 
    height: 15px; 
    border: 0; 
} 
#iframeMainMenu 
{ 
    width: 200px; 
    height: 100%; 
} 
#iframeCenterContent 
{ 
    width: 100%; 
    height: 100%; 
    top: 65px; 
    left: 200px; 
    position: fixed; 
} 
#iframeFooter 
{ 
    width: 100%; 
    height: 50px; 
    bottom: 0px; 
    left: 200px; 
    position: fixed; 
} 

HTML

<div id="layoutContainer"> 
    <iframe id="iframeHeader" src="#" frameborder="0" hspace="0" vspace="0" marginheight="0" marginwidth="0"></iframe> 
    <iframe id="iframeStatusBar" src="#" frameborder="0" hspace="0" vspace="0" marginheight="0" marginwidth="0"></iframe> 
    <iframe id="iframeMainMenu" src="#"></iframe> 
    <iframe id="iframeCenterContent" src="#"></iframe> 
    <iframe id="iframeFooter" src="#"></iframe>    
</div> 

当我运行在Chrome中我实际的代码,它显示如图所示灰色边框:
enter image description here

+0

你试试您收到的解决方案 – dippas

+0

当然,我尝试了解决方案。这就是为什么我说现有的答案没有帮助。 – Nav

+0

你能给这个网站的链接吗?正如你可以看到我的代码片段正在工作。 – dippas

回答

8

只是添加到您的CSS:

iframe {  
border: 0; 
} 

参见下面的代码片段:

* { 
 
    -webkit-box-sizing: border-box; 
 
    -moz-box-sizing: border-box; 
 
    box-sizing: border-box; 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 
html { 
 
    height: 100%; 
 
} 
 
body { 
 
    height: 100%; 
 
    background: #FEFFFB; 
 
    font-family: arial, verdana; 
 
} 
 

 
/*ADD THIS BELOW */ 
 
iframe { 
 
    border: 0 ; 
 
} 
 
/*END*/ 
 

 
#layoutContainer { 
 
    width: 100%; 
 
    height: 100%; 
 
    top: 0px; 
 
    left: 0px; 
 
    position: fixed; 
 
} 
 
#iframeHeader { 
 
    width: 100%; 
 
    height: 50px; 
 
    border: 0; 
 
} 
 
#iframeStatusBar { 
 
    width: 100%; 
 
    height: 15px; 
 
    border: 0; 
 
} 
 
#iframeMainMenu { 
 
    width: 200px; 
 
    height: 100%; 
 
} 
 
#iframeCenterContent { 
 
    width: 100%; 
 
    height: 100%; 
 
    top: 65px; 
 
    left: 200px; 
 
    position: fixed; 
 
} 
 
#iframeFooter { 
 
    width: 100%; 
 
    height: 50px; 
 
    bottom: 0px; 
 
    left: 200px; 
 
    position: fixed; 
 
}
<div id="layoutContainer"> 
 
    <iframe id="iframeHeader" src="#" frameborder="0" hspace="0" vspace="0" marginheight="0" marginwidth="0"></iframe> 
 
    <iframe id="iframeStatusBar" src="#" frameborder="0" hspace="0" vspace="0" marginheight="0" marginwidth="0"></iframe> 
 
    <iframe id="iframeMainMenu" src="#"></iframe> 
 
    <iframe id="iframeCenterContent" src="#"></iframe> 
 
    <iframe id="iframeFooter" src="#"></iframe> 
 
</div>

+0

工程。谢谢 – Nav

+0

很高兴为您效劳 – dippas

1

另一种方式做,这是FRAMEBORDER =“0”,我看你已经试过,但错过了大写字母“B”