五月综合缴情婷婷六月,色94色欧美sute亚洲线路二,日韩制服国产精品一区,色噜噜一区二区三区,香港三级午夜理伦三级三

您現(xiàn)在的位置: 365建站網(wǎng) > 365文章 > HTML iframe設(shè)置背景透明的方法

HTML iframe設(shè)置背景透明的方法

文章來源:365jz.com     點擊數(shù):591    更新時間:2017-08-10 11:51   參與評論

IE5.5開始支持浮動框架的內(nèi)容透明。如果想要為浮動框架定義透明內(nèi)容,則必須滿足下列條件。
1.與 iframe 元素一起使用的 allowTransparency 標簽屬性必須設(shè)置為 true。
2.在 iframe 內(nèi)容源文檔,background-color 或 body 元素的 bgColor 標簽屬性必須設(shè)置為 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頁面中沒有設(shè)置顏色.
在上面我們主要是看到了style中的一句代碼style="background-color=transparent" 通過以下四種IFRAME的寫法我想大概你對iframe背景透明效果的實現(xiàn)方法應(yīng)該會有個清晰的了解:
<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)在我們來看一個實例
本例主要是iframe對象的allowTransparency屬性應(yīng)用,在該屬性設(shè)置為true并且iframe所載加頁的背景顏色設(shè)置為transparent(透明)時iframe將透明化。 
allowTransparency設(shè)置或獲取對象是否可為透明。 
bgColor 設(shè)置或獲取對象的背景顏色

 

父頁面

<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>
 

其它方法:

框架頁文件設(shè)置:
<body style="background-color:transparent" > 或 <body bgColor="transparent">
方法一:
<iframe src="about.htm" width="100%" height="100%" align="center" scrolling="auto" frameborder="0" style="filter:chroma(color=#ffffff)" >
</iframe>
缺點:iFrame里的白色的都變透明了。
方法二:(個人推薦使用)
<iframe src="about.htm" width="100%" height="100%" align="center" scrolling="auto" frameborder="0" allowTransparency="true" >
</iframe>
還有其它幾個寫法,可以比較一下:
<iframe src="about.htm" allowTransparency="true" style="background-color: green"> </iframe >
<iframe src="about.htm"> </iframe >

<iframe src="about.htm" style="background-color: green"> </iframe >  

 

經(jīng)測試,<body style="background-color:transparent" >  +  allowTransparency="true" 有效

如對本文有疑問,請?zhí)峤坏浇涣髡搲瑥V大熱心網(wǎng)友會為你解答!! 點擊進入論壇

發(fā)表評論 (591人查看,0條評論)
請自覺遵守互聯(lián)網(wǎng)相關(guān)的政策法規(guī),嚴禁發(fā)布色情、暴力、反動的言論。
昵稱:
最新評論
------分隔線----------------------------

其它欄目

· 建站教程
· 365學(xué)習(xí)

業(yè)務(wù)咨詢

· 技術(shù)支持
· 服務(wù)時間:9:00-18:00
365建站網(wǎng)二維碼

Powered by 365建站網(wǎng) RSS地圖 HTML地圖

copyright © 2013-2024 版權(quán)所有 鄂ICP備17013400號