【问题标题】:I would like to set an iframe as a background using css我想使用 css 将 iframe 设置为背景
【发布时间】:2015-06-17 00:08:28
【问题描述】:

亲爱的程序员@stackoverflow,

是否可以使用 css 将 iframe 设置为背景?

我再解释一下自己:

今天我的网站中有一个名为 div="lead"
当我在 html 文件中使用该 div 时,图片“lead_photo.jpg”显示为背景。
我在我的 css 文件中使用的代码是:

#lead { position: relative; float: left; clear: both; 
        width: 100%; height: 300px;
        background: #dbdbdb url(../images/lead_photo.jpg) center no-repeat; }

到目前为止一切顺利。

现在,我想在我的网站上显示我应该使用 iframe 链接集成的“google business view-tour”,而不是当前照片。

这可能吗?

【问题讨论】:

  • 您必须绝对定位 iframe,并且 z 索引低于其他元素。
  • 问题解决了!谢谢;-)
  • 记得添加您自己的答案并标记为已解决,它对社区有帮助;)
  • 嗨@filip,我想对你想要实现的目标做同样的事情,但我还是找不到怎么做?你有那个答案了吗?我的目标是让谷歌地图 iframe 作为我部分的背景。

标签: jquery html css iframe


【解决方案1】:

在 css 中使用此文本对我来说效果很好:

#iframe { position: absolute; float: left; clear: both; width: 100%; height: 350px; z-index: 0; left no-repeat; }

后记我在 html 中使用了div="iframe"

感谢 4 帮助我!

【讨论】:

    【解决方案2】:

    你试试这个CSS来给我们设置背景图片。 另外,请检查图片的路径是否正确。

    #lead { 
        position: relative; 
        float: left; 
        clear: both; 
        width: 100%; 
        height: 300px;
        background-image:  #dbdbdb, url(images/lead_photo.jpg);
        background-position: center no-repeat; 
    }
    

    您为此 CSS 设置颜色和图像并设置背景图像。

    【讨论】:

      猜你喜欢
      • 2022-06-10
      • 2020-03-03
      • 1970-01-01
      • 2021-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多