两个问题——如何用CSS&定位 div、表格等可以重叠吗?

发布于 2024-07-29 07:02:37 字数 255 浏览 0 评论 0原文

我正在尝试将桌子向上移动 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

拿命拼未来 2024-08-05 07:02:37
.subNavBar {
    position: absolute/relative;
    margin-top: -6px;
}

顺便说一句:恕我直言,您可以将任何东西与任何东西重叠。 position:absolutez-index 是你的朋友。 ;-)

.subNavBar {
    position: absolute/relative;
    margin-top: -6px;
}

Btw: You can IMHO overlap anything with anything. position: absolute and z-index are your friends. ;-)

梦毁影碎の 2024-08-05 07:02:37

负边距可能会在某些浏览器中引起问题(这里指的是你,旧的 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 :(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文