最近、私は頻繁にiframeを使用して、プロジェクト作業中にページの階層フレームワークを描画する必要があります。ほとんどのブラウザには背景がありませんが、IFRAMEはIEでデフォルトで白い背景色を持っています。主な背景色が白でない場合、この部分では突然に見えます。ソリューションは、ヘルプマニュアル、つまり、iframeの許容範囲のプロパティをtrueに設定し、それを行うことができます。対応する例は、次のように、ヘルプドキュメントにも示されています。
コードをコピーします
コードは次のとおりです。
<body style = "background-color:red">
<iframe id = "frame1" src = "transparentbody.htm" approstransparency = "true">
</iframe>
<iframe id = "frame2" src = "transparentbody.htm" approstransparency = "true"
style = "background-color:緑">
</iframe>
<iframe id = "frame3" src = "transparentbody.htm">
</iframe>
<iframe id = "frame4" src = "transparentbody.htm"
style = "background-color:緑">
</iframe>
</body>
理論的には、これを行うのに問題はありませんが、IEは大きな反応を持っていないようであり、まだ白い背景を持っています。実際、この時点で、サブページの<body>タグに<body bgcolor = "透明">を追加する必要があります。例は次のとおりです。
http://img.blog.csdn.net/20140610165850968?watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqva3 vucgvuz19tdwjhbw ==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma ==/溶解/70/重力/センター
main.htmlメインページコード:
コードをコピーします
コードは次のとおりです。
<html>
<head>
<title> </title>
</head>
<body style = "background-color:blue;">
<表
style = "width:100%; border:0; height:100%; cellpadding:0; cellpacing:0">
<tr height = "100%">
<td height = "100%" width = "30%">
<iframe id = "test1" src = "test1.html" approstransparency = "true" width = "100%" height = "100%"> </iframe> </td>
<td height = "100%" width = "40%">
<iframe id = "test2" src = "test2.html" approstransparency = "true" width = "100%" height = "100%"> </iframe> </td>
<td height = "100%" width = "30%">
<iframe id = "test3" src = "test3.html" width = "100%" height = "100%"> </iframe> </td>
</tr>
</table>
</body>
</html>
test1.htmlページコード:
コードをコピーします
コードは次のとおりです。
<html>
<head>
<title> </title>
</head>
<body bgcolor = "透明">
<h1> test1 </h1>
</body>
</html>
test2.htmlページコード:
コードをコピーします
コードは次のとおりです。
<html>
<head>
<title> </title>
</head>
<body>
<h1> test2 </h1>
</body>
</html>
test3.htmlページコード:
コードをコピーします
コードは次のとおりです。
<html>
<head>
<title> </title>
</head>
<body>
<h1> test3 </h1>
</body>
</html>
この小さな例は、主にiframeタグの許容トランスペアン性プロパティアプリケーションです。プロパティがtrueに設定され、iframeによってロードされたサブページの<body>タグの背景色が透過的に設定されている場合(透明)。
トランスペパリティセットを許可するか、オブジェクトが透過的であるかどうかを取得します。
bgcolorは、オブジェクトの背景色を設定または取得します。