两个问题——如何用CSS&定位 div、表格等可以重叠吗?
我正在尝试将桌子向上移动 6 像素。
其上方有一张桌子,因此这意味着它们必须重叠。 这可能吗?
我已经尝试过
.subNavBar {
position: relative;
top: -6px;
}
并且
.subNavBar {
position: absolute;
top: -6px;
}
I am trying to move a table up by 6px.
There is a table immediately above it, so this means they will have to overlap. Is this possible?
I have tried
.subNavBar {
position: relative;
top: -6px;
}
and
.subNavBar {
position: absolute;
top: -6px;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
顺便说一句:恕我直言,您可以将任何东西与任何东西重叠。
position:absolute
和z-index
是你的朋友。 ;-)Btw: You can IMHO overlap anything with anything.
position: absolute
andz-index
are your friends. ;-)负边距可能会在某些浏览器中引起问题(这里指的是你,旧的 IE)。 此外,当边距为负时,位置属性也无关紧要。
我很惊讶你的第一次尝试 {position:relative; top: -6px;} 没有达到你想要的效果。 我就是这样做的,它在 FF3、IE7、Chrome2、Safari4 和 Opera9.61 中对我来说工作得很好
这是我测试的内容,所以你可以看到代码: http://www.darine.org/table_overlap.htm
如果您对表格样式执行的其他操作导致出现这种情况更复杂,我不能保证没有冲突:(
Negative margins can cause problems in some browsers (here's looking at you, old IE). Also, with a negative margin the position attribute is irrelevant.
I'm surprised that your first attempt {position: relative; top: -6px;} didn't achieve what you wanted. It's how I would have done it, and it works fine for me in FF3, IE7, Chrome2, Safari4 and Opera9.61
Here's what I did to test, so you can see the code: http://www.darine.org/table_overlap.htm
If there is anything else you're doing with your table styles that make the situation more complex, I can't guarantee no conflicts :(
这里有一个非常好的CSS定位介绍
Here is a very good introduction to css positioning