首頁 > web前端 > js教程 > 主體

iframe背景透明的設定方法

高洛峰
發布: 2016-12-24 16:55:10
原創
1251 人瀏覽過

IE5.5開始支援浮動框架的內容透明。如果想要為浮動框架定義透明內容,則必須滿足下列條件。 
1.與 iframe 元素一起使用的 allowTransparency 標籤屬性必須設為 true。
2.在iframe 內容來源文檔,background-color 或body 元素的bgColor 標籤屬性必須設定為transparent

<iframe src="./ads_top_tian.html" allowtransparency="true" style="background-color=transparent" title="test" frameborder="0" width="470" height="308" scrolling="no"></iframe>
登入後複製

當然前提是iframe頁面中沒有設定顏色.
在上面我們主要是看到了style中的一句程式碼style ="background-color=transparent" 透過以下四種IFRAME的寫法我想大概你對iframe背景透明效果的實現方法應該會有個清晰的了解:

<IFRAME ID="Frame1" SRC="transparentBody.htm" allowTransparency="true"></IFRAME>
<IFRAME ID="Frame2" SRC="transparentBody.htm" allowTransparency="true" STYLE="background-color: green"> </IFRAME>
<IFRAME ID="Frame3" SRC="transparentBody.htm"></IFRAME>
<IFRAME ID="Frame4" SRC="transparentBody.htm" STYLE="background-color: green"> </IFRAME>
登入後複製

現在我們來看一個實例
本例主要是iframe物件的allowTransparency屬性應用,在該屬性設為true並且iframe所載加頁的背景顏色設定為transparent(透明)時iframe將透明化。 
allowTransparency設定或取得物件是否可為透明。 
bgColor 設定或取得物件的背景顏色

父頁

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>父页面</title>
</head>
<body bgcolor="#FF0000">
<iframe src="index.htm"  allowTransparency="true"></iframe>
</body>
</html>
登入後複製

子頁

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>子页面</title>
<style type="text/css">
body
{
    background-color: transparent; 
}
</style>
</head>
<body>
</body>
</html>
登入後複製


父頁

rrreee
子頁

rrreee


🎜🎜iframee透明的更多中文設定方法相關文章! 🎜🎜🎜🎜
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!