2014-07-11 23 views
-1

試圖嵌入一個博客到我們的HTML網站,與一個iFrame#:但是HTML IFRAME不會得到更高

<h1 class="title">All the latest...</h1> 
</br> 
</div> 
    </div> 
     </div> 
     <iframe src ="http://inspireacademy.tumblr.com" width="100%" height="auto"> 
     <p>Your browser does not support iframes.</p> 
     </iframe> 

我試圖改變高度爲100%,汽車,甚至很多固定的寬度, iframe的高度保持不變!任何幫助?

由於提前,

艾丹

+0

可能重複[如何使HTML IFRAME 100%寬度和高度?](http://stackoverflow.com/questions/3306124/how-to-make-a-html-iframe-100-width-and -高度) – melancia

回答

0

如果您使用的是百分比,則包含的元素必須有一個高度或將的iFrame不知道該怎麼立足於百分比。如果您給身體100%的身高,然後給予100%身高的iFrame,它將填滿窗戶的整個高度。

此外,我建議不要使用內聯CSS,而是將您的CSS規則放入CSS文件中。

HTML:

<body> 
<iframe src ="http://inspireacademy.tumblr.com"> 
    <p>Your browser does not support iframes.</p> 
</iframe> 
</body> 

CSS:

body { 
    height:100%; 
} 
iframe { 
    height:100%; 
    width:100%; 
} 

JSFiddle

0

您必須設置包含div的高度。高度自動使用元素所在的容器來設置高度。高度僅在容器中以百分比形式工作。

<h1 class="title">All the latest...</h1></br> 
</div> 
    </div> 
     </div> 
     <div style="height:400px;"> 
      <iframe src ="http://inspireacademy.tumblr.com" width="100%" height="auto"> 
       <p>Your browser does not support iframes.</p> 
      </iframe> 

然後它將縮放到容器。