需求:在一个div里面嵌套一个iframe(src="ui.html"),div有背景图片,要让iframe里的内容透明地显示在div层上。

      刚开始直接把iframe放在div中,结果iframe的背景(默认为白色)挡住了div层的背景,后来在ui.html的最外层div的style上加了background:transparent;属性,FF下显示透明,但在IE下iframe的背景为透明的(改变桌面的窗口颜色 ,效果会更清晰),依然挡住了div层的背景。后来又在iframe标签上加了一个 allowtransparency="true"属性,OK这下就满足需求啦。完整HTML如下:

div:

<div style="width:900px;height:30px;background:url("/img/l.gif") repeat-x;text-align:left">  
    <iframe width="300px" height="30px" style="float:left;" frameborder="0" scrolling="no" align="top" src="/ui.html"></iframe>  
</div>  

 ui.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html>  
  <head>  
  </head>  
  <body style="background:transparent;">  
    <div >  
        欢迎大家光临!!!  
    </div>  
  </body>  
</html>  

 

相关文章:

  • 2021-08-24
  • 2021-11-27
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2022-02-24
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2022-12-23
  • 2021-11-06
  • 2021-12-15
  • 2022-12-23
  • 2022-01-27
  • 2021-07-25
相关资源
相似解决方案