如何将 2 个相对 div 相互放置/顶部 css 属性在不同浏览器中有所不同,使用 css 使它们在所有浏览器中显示相同?
我有以下 div 元素:
<div id="banner1">
<div id="whiteout"></div>
<div id="banner2"></div>
</div>
我需要: 'whiteout' 元素直接出现在 'banner1' 和 'banner2' 之上,并使其在所有浏览器中显示相同(目前 Firefox 和 IE 似乎很难显示即使 'top' css 属性以像素为单位,它也是正确的)- 或者,有人可以告诉我如何相互显示 2 个相对的 div 吗?
目前,我的CSS如下:
div#banner1 {
width: 100%;
height: 140px;
background-image: url( "images/banner/1.png" );
background-position: center center;
background-size: 100% 100%;
background-repeat: no-repeat;
border-collapse: collapse;
}
div#banner2 {
width: 100%;
height: 140px;
background-position: center center;
background-size: 100% 100%;
background-repeat: no-repeat;
border-collapse: collapse;
}
div#whiteout {
border: 1px solid black;
width: 500px;
height: 140px;
background-image: url( "images/whiteout.png" );
background-position: left center;
background-repeat: no-repeat;
border-collapse: collapse;
position: absolute;
z-index: 1;
display: block;
top: 50px;
}
真诚感谢您的帮助或建议! :)
彼得。
I have the following div elements:
<div id="banner1">
<div id="whiteout"></div>
<div id="banner2"></div>
</div>
I need either: the 'whiteout' element to appear directly on top of 'banner1' and 'banner2'and having it display the same in all browsers (currently Firefox and IE seem to have a hard time displaying it properly even though the 'top' css property is in pixels) -
alternatively, could someone please tell me how to display 2 relative divs over each other?
Currently, my css is as follows:
div#banner1 {
width: 100%;
height: 140px;
background-image: url( "images/banner/1.png" );
background-position: center center;
background-size: 100% 100%;
background-repeat: no-repeat;
border-collapse: collapse;
}
div#banner2 {
width: 100%;
height: 140px;
background-position: center center;
background-size: 100% 100%;
background-repeat: no-repeat;
border-collapse: collapse;
}
div#whiteout {
border: 1px solid black;
width: 500px;
height: 140px;
background-image: url( "images/whiteout.png" );
background-position: left center;
background-repeat: no-repeat;
border-collapse: collapse;
position: absolute;
z-index: 1;
display: block;
top: 50px;
}
Thanks sincerely for any help or suggestion! :)
Piotr.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
或者假设高度为 140px
调整它以获得准确的结果
OR assumiong the height of 140px
Tweak it to get exact results