我有一個iframe。內容比我設置的寬度更寬,以便iframe獲取水平滾動條。我無法增加iframe的寬度,所以我只想刪除滾動條。我嘗試將滾動屬性設置爲「否」,但是這會殺死兩個滾動條,我想要垂直滾動條。我試着將overflow-x設置爲「隱藏」,並在ff中殺死了水平滾動條,但在IE中沒有。我傷心。可怕的iframe水平滾動條不能在IE中刪除?
回答
scrolling="yes" horizontalscrolling="no" verticalscrolling="yes"
將其放入您的iFrame標籤中。
你不需要在CSS中嘗試格式化它。
您可以嘗試將iframe放入div中,然後使用div進行滾動。你可以控制在IE瀏覽器中的滾動沒有問題,IE瀏覽器只有真正有問題的iframe滾動。這是一個應該做的訣竅的簡單例子。
<html>
<head>
<title>iframe test</title>
<style>
#aTest {
width: 120px;
height: 50px;
padding: 0;
border: inset 1px #000;
overflow: auto;
}
#aTest iframe {
width: 100px;
height: 1000px;
border: none;
}
</style>
</head>
<body>
<div id="aTest">
<iframe src="whatever.html" scrolling="no" frameborder="0"></iframe>
</div>
</body>
</html>
滾動條不是的屬性,它是它所包含頁面的屬性。嘗試將overflow-x: hidden
放在內頁的<html>
元素上。
與身體元素一起工作。謝謝! – 2011-04-21 01:51:45
這個解決方案要好得多,以保持iframe代碼輕而易舉封裝。我不應該記得添加和記住語法。 – 2011-09-29 17:42:29
我同意@DannyG。我們已經超越了我們標記中呈現屬性的時代。純粹的CSS解決方案由於多種原因而更可取。 – DuxPrime 2012-08-01 17:11:47
<iframe style="overflow:hidden;" src="about:blank"/>
應該在IE中工作。 IE6有支持overflow-x和overflow-y的問題。
還有一點需要注意的是,只有在camelCase中設置「frameborder」屬性時,iframe上的IE邊框才能被刪除。
<iframe frameBorder="0" style="overflow:hidden;" src="about:blank"/>
這將是很好,如果你可以用CSS正確的樣式,但它不適用於IE瀏覽器。
所有這些解決方案都不適合我或不滿意。使用可滾動的DIV,您可以使水平滾動條消失,但您始終擁有垂直滾動條。
因此,對於我可以確保控制所有iframe的固定高度的網站,以下解決方案效果非常好。 它只是隱藏了DIV :)
<!-- This DIV is a special hack to hide the horizontal scrollbar in IE iframes -->
<!--[if IE]>
<div id="ieIframeHorScrollbarHider" style="position:absolute; width: 768px; height: 20px; top: 850px; left: 376px; background-color: black; display: none;">
</div>
<![endif]-->
<script type="text/javascript">
if (document.getElementById("idOfIframe") != null && document.getElementById("ieIframeHorScrollbarHider") != null)
{
document.getElementById("ieIframeHorScrollbarHider").style.display = "block";
}
</script>
您也可以嘗試設置,隨機配備的iframe至99%內頁的車身寬度的水平滾動條。
- 1. 刪除iframe水平滾動條
- 2. 刪除水平滾動條
- 3. 刪除水平滾動條
- 4. 刪除水平滾動條
- 5. 刪除水平滾動條
- 6. 刪除垂直滾動條,在Chrome中保持iframe中的水平滾動條
- 7. 如何從div/iframe中刪除此水平滾動條?
- 8. 刪除水平滾動條Godaddy的HTML
- 9. 刪除水平滾動條的空間
- 10. 刪除textarea的水平滾動條
- 11. iframe中的水平滾動條
- 12. 無法從iframe刪除水平滾動條
- 13. C#WinForms TreeView刪除水平滾動條
- 14. 如何刪除水平滾動條CSS3
- 15. 如何刪除水平滾動條?
- 16. 如何刪除水平滾動條?
- 17. 水平滾動uitableview刪除條目
- 18. 如何刪除水平滾動條
- 19. 如何刪除水平滾動條
- 20. 刪除或隱藏水平滾動條
- 21. 溢出隱藏不從IE中的jQuery循環中刪除水平滾動條
- 22. 如何禁用水平滾動? (不去除水平滾動條)
- 23. 如何刪除標籤功能中的水平滾動條
- 24. 刪除水平滾動
- 25. 刪除水平滾動
- 26. IFrame水平滾動條煩惱
- 27. 垂直滾動條在水平滾動條內不可見android
- 28. 如何從父框架滾動iFrame中的水平滾動條?
- 29. 刪除手機中的水平滾動
- 30. WPF水平滾動條不可見
謝謝你的解決方案。唯一的問題是,你必須爲iframe內容定義一個固定的高度,這在我的情況下會有所不同。我將使用這個,並將不得不指定一個額外的高度的iframe這是有點hacky。但是非常感謝,這讓我感到很開心。 – mrjrdnthms 2008-09-16 17:55:20