html - iframe 播放器和上面的横幅

标签 html css

<分区>


想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post .

关闭 5 年前

您好,我想让横幅出现在 iframe 播放器上。像这样:http://i.imgur.com/nbcSVPP.png当然有一个关闭按钮。 我的html代码是这样的

<div id="content-embed" style="min-height: 500px;">                 
    <iframe id="iframe-embed" width="100%" height="500px" scrolling="no" frameborder="0" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true">
    </iframe>
</div>

CSS

#content-embed {
    width: 100%;
    position: relative;
}

到目前为止我尝试了什么(抱歉,我不精通 css 和 html)

<div id="content-embed" style="min-height: 500px;">                 
    <iframe id="iframe-embed" width="100%" height="500px" scrolling="no" frameborder="0" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" style="z-index: 0;">
    </iframe>
    <div style="z-index: 1;"><img src="/banner.jpg" /></div>
</div>

最佳答案

需要在iframe和图片的wrapper中使用position: relative,然后在图片中使用position: absolute来设置它在元素中的位置,如示例所示:

https://jsfiddle.net/kLaj5gjj/

.relative-wrapper {
  position: relative;
}

.iframe {
  /* simulating iframe */
  width: 500px;
  height: 300px;
  background-color: black;
}

.banner {
  /* banner positioning */
  position: absolute;
  top: 50%;
  left: 40%;
}

.some-image {
  /* simulating image size */
  width: 200px;
  height: 50px;
  background-color: red;
}
<div class="relative-wrapper">
  <!-- simulating iframe -->
  <div class="iframe"></div>
  
  <div class="banner">
    <!-- simulatin image -->
    <img class="some-image" />
  </div>
</div>

关于html - iframe 播放器和上面的横幅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45130833/

上一篇:javascript - 将 id 作为参数传递

下一篇:javascript - 当图像 src 不为空时更改 css 类

相关文章:

html - lesscss之谜

HTML 呈现问题和正在呈现的额外标记

javascript - 子div溢出时强制父div放大

html - 如何更改 Foundation Zurb 背景?

html - 如何使用CSS排列带有半径的div结构

HTML、CSS 粘性页脚(不断增长的内容)

html - 将所有 Bootstrap 内容放入可视区域

javascript - Firefox css3 动画

html - 使表格与连续的图片内联

html - 当我在 HTML/CSS 中单击映射到我的图像的热点时,如何删除蓝色边框?