2015-04-27 47 views
0

我想要在CSS中使用調整大小功能來調整div的大小。在我的.css文件我有:無法在iframe中調整大小

#test { 
    border: 2px solid; 
    padding: 20px; 
    width: 300px; 
    resize: both; 
    overflow: auto; 
} 

我的div如下:

<div id="test">Let the user resize both the height and the width of this div element.</div> 

它正常工作,直到我把我的HTML中的iframe,還有我無法調整的股利。怎麼了?

PS:我不」想使用jquery

回答

2

IFrame,這是作爲一個新的網站來處理。要將你的CSS應用到你的iframe中 - 只需在你的iframe中設置對你的樣式表的引用。

<iframe id="frame"></iframe> 

<script> 
document.getElementById('iframe').contentWindow.document.write("<html><head>" + 
"<link rel='stylesheet' href='style.css'>" + 
"</head><body><div id='test'></div></body></html>"); 
</script> 

通過這個您的IFRAME將訪問你的樣式correclty