对于所有浏览器来说,让一个图像在 html 页面上与另一个图像重叠的最佳方法是什么
我有两个跨度:
<span id="top" ><img src="top.png" /></span>
<span id="bottom" ><img src="bottom.png" /></span>
我怎样才能将它放在哪里:
- 顶部图像与底部图像重叠
- 确保顶部图像显示在底部图像的前面(而不是后面)
- 确保跨浏览器的对齐方式一致
i have two spans:
<span id="top" ><img src="top.png" /></span>
<span id="bottom" ><img src="bottom.png" /></span>
how can i have it where:
- The top image overlaps over the bottom image
- Make sure the top images shows up in front of the bottom image) (instead of behind it)
- make sure that alignment is consistent across browsers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
@ooo;您可以将
position:relative
赋予您的范围,因为z-index
仅适用于绝对位置和位置相对
就像这样:css:
html:
@ooo; you can give
position:relative
to your span becausez-index
works only onposition absolute & relative
right like this:css:
html:
这应该与它们有一点重叠。 CSS 实际上取决于它们应该重叠多少......
That should overlap them a bit. The CSS really depends on how much they are supposed to overlap...
将元素包裹在容器中;
将容器的css设置为
position:relative;
然后使用;
使用
left
和top
来定位图像。这应该会在浏览器之间提供最一致的结果。由于元素可能容易受到早期版本 IE 中存在的双边距错误的影响,因此它应该比使用边距来定位图像受到特别青睐。
Wrap the elements in a container;
Set the css of the container to
position: relative;
Then use;
Using
left
andtop
to position your images.This should give the most consistent result across browsers. It should be especially favoured over the use of margins to position the images due to the potential of elements being susceptible to the double margin bug present in earlier versions of IE.