在 XHTML Strict 中实现深度
我想在下实现
,换句话说,div将是可见的,因为表格中有透明的png,但它会在
后面。
有谁知道该怎么做?
我尝试了 float:left
和不同的 z-index
,但无济于事。
I would like to implement <div>
beneath a <table>
, in other words, the div will be visible, as the table has transparent png's in but it will behind the <table>
.
Does anyone know how to do this?
I tried float:left
and differing z-index
's, but to no avail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你走在正确的轨道上。但使用 Z 索引时,元素也必须是绝对定位的。
这是一个使用 div 的示例,但它也可能是表格...
CSS:
HTML:
You're on the right track. But when using the Z-index, your elements must also be absolute-positioned.
Here's an example using divs, but it may as well be tables...
CSS:
HTML:
z-index 仅适用于绝对定位的元素。您可以尝试设置
position:absolute
,然后使用top、right、bottom、left
样式将元素放置在彼此的顶部。您也可以尝试将
float: left
,然后使用负margin-left 将表格向左移动,将其放置在 div 的顶部值。
例如:
使用以下 CSS,第二个 div 将距离第一个 div 50px。
第二个 div 就是你的桌子。使用 div 更容易演示:)
z-index only works on absolutely positioned elements. You could try setting
position: absolute
and then using thetop, right, bottom, left
styles to position the elements on top of each other.You could also try putting the <div> in front of the table in the markup, set
float: left
on the div, and them move the table left, to position it on top of the div, by using a negativemargin-left
value.For example:
Using the following CSS, the second div would be 50px into the first div.
The second div there would be your table. Just easier to demonstrate with divs :)
只是补充一下前两个答案。 Z-index 不仅限于那些绝对定位的元素。 Z-index 也适用于具有相对定位的元素。
Just to add to the previous two answers. Z-index is not limited to only those elements that are positioned absolutely. Z-index also works on elements that have relative positioning.