jquery - 在所有浏览器的 html 页面上,让一张图片与另一张图片重叠的最佳方式是什么

标签 jquery html css image z-index

我有两个跨度:

<span id="top" ><img src="top.png" /></span>
<span id="bottom" ><img src="bottom.png" /></span>

我怎样才能把它放在哪里:

  1. 顶部图像重叠在底部图像上
  2. 确保顶部图像显示在底部图像的前面)(而不是在它后面)
  3. 确保对齐方式在浏览器之间保持一致

最佳答案

@哦;你可以给你的跨度 position:relative 因为 z-index 只适用于 position absolute & relative 就像这样:

CSS:

span{position:relative;display:block}
#top{z-index:1;}
#bottom{margin-top:-20px}

html:

<span id="top" ><img src="top.png" /></span>
<span id="bottom" ><img src="bottom.png" /></span>

关于jquery - 在所有浏览器的 html 页面上,让一张图片与另一张图片重叠的最佳方式是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7446939/

相关文章:

jquery - 幻灯片重叠页脚

javascript - 更有效的数字比较

php - Magento 将横幅添加到自定义 phtml

html - 在 html、css 中隐藏边框后面的图像

javascript - 对象标签加载 SVG 但其内容文档为空

javascript - 除一个元素外的所有元素都易于过渡

移动设备上覆盖默认视频播放按钮的CSS

javascript - onclick 事件跟踪不起作用

html - 如何按组布置列表项

html - Twitter-Bootstrap4 : Make a DIV occupy height (100% - navbar)