Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

CSS系列之如何理解z-index和层叠上下文 #18

Open
yuanyuanbyte opened this issue Nov 12, 2021 · 0 comments
Open

CSS系列之如何理解z-index和层叠上下文 #18

yuanyuanbyte opened this issue Nov 12, 2021 · 0 comments
Assignees

Comments

@yuanyuanbyte
Copy link
Owner

如何理解z-index?

z-index 属性指定一个元素的堆叠顺序。

当元素之间重叠的时候, z-index 较大的元素会覆盖较小的元素在上层进行显示。

如何理解层叠上下文?

层叠上下文是HTML元素的三维概念,这些HTML元素在一条假想的相对于面向(电脑屏幕的)视窗或者网页的用户的z轴上延伸。

在这里插入图片描述

在层叠上下文中,子元素同样也按照上面解释的规则进行层叠。 重要的是,其子级层叠上下文的 z-index 值只在父级中才有意义。子级层叠上下文被自动视为父级层叠上下文的一个独立单元。

@yuanyuanbyte yuanyuanbyte self-assigned this Nov 12, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant