iframe背景透明的設(shè)置方法
更新時間:2013年11月08日 10:45:24 作者:
本文收集各種關(guān)于解決iframe 背景透明設(shè)置方法與實(shí)例分析
IE5.5開始支持浮動框架的內(nèi)容透明。如果想要為浮動框架定義透明內(nèi)容,則必須滿足下列條件。
1.與 iframe 元素一起使用的 allowTransparency 標(biāo)簽屬性必須設(shè)置為 true。
2.在 iframe 內(nèi)容源文檔,background-color 或 body 元素的 bgColor 標(biāo)簽屬性必須設(shè)置為 transparent
復(fù)制代碼 代碼如下:
<iframe src="./ads_top_tian.html" allowtransparency="true" style="background-color=transparent" title="test" frameborder="0" width="470" height="308" scrolling="no"></iframe>
當(dāng)然前提是iframe頁面中沒有設(shè)置顏色.
在上面我們主要是看到了style中的一句代碼style="background-color=transparent" 通過以下四種IFRAME的寫法我想大概你對iframe背景透明效果的實(shí)現(xiàn)方法應(yīng)該會有個清晰的了解:
復(fù)制代碼 代碼如下:
<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>
現(xiàn)在我們來看一個實(shí)例
本例主要是iframe對象的allowTransparency屬性應(yīng)用,在該屬性設(shè)置為true并且iframe所載加頁的背景顏色設(shè)置為transparent(透明)時iframe將透明化。
allowTransparency設(shè)置或獲取對象是否可為透明。
bgColor 設(shè)置或獲取對象的背景顏色
父頁面
復(fù)制代碼 代碼如下:
<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>
子頁面
復(fù)制代碼 代碼如下:
<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>
相關(guān)文章
Lesson03_01 什么是CSS和CSS的設(shè)置方式
Lesson03_01 什么是CSS和CSS的設(shè)置方式...2007-02-02
css列表標(biāo)簽list與表格標(biāo)簽table詳解
這篇文章主要介紹了css列表標(biāo)簽list與表格標(biāo)簽table詳解的相關(guān)資料,需要的朋友可以參考下2019-01-01
CSS網(wǎng)頁布局入門教程2:一列自適應(yīng)寬度
CSS網(wǎng)頁布局入門教程2:一列自適應(yīng)寬度...2007-09-09

