为什么z-index不工作? [英] Why does z-index not work?
问题描述
因此,如果我正确理解 z-index
,这将是完美的:
我想放置底部图片(标签/卡)下面的div。所以你看不到锋利的边缘。我如何做到这一点?
z-index:-1 //图像标签/卡
或
index:100 //在上面的div上
也不是这样的组合。如何来?
解决方案 z-index
仅适用于具有(< c>)之外的/CSS21/visuren.html#propdef-position> position
code> position:absolute;
, position:relative;
或 position:fixed $ c $
在Firefox中还支持 position:sticky;
在一个自定义标志下在旧版本的Chrome中工作了一段时间,微软正在考虑添加到他们的Edge浏览器。
So if I understand z-index
correctly, it would be perfect in this situation:
I want to place the bottom image (the tag/card) below the div above it. So you can't see the sharp edges. How do I do this?
z-index:-1 // on the image tag/card
or
z-index:100 // on the div above
doesn't work either. Neither does a combination of anything like this. How come?
解决方案 The z-index
property only works on elements with a position
value other than static
(e.g. position: absolute;
, position: relative;
, or position: fixed
).
There is also position: sticky;
that is supported in Firefox, is prefixed in Safari, worked for a time in older versions of Chrome under a custom flag, and is under consideration by Microsoft to add to their Edge browser.
这篇关于为什么z-index不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!