Comments (6)
宿主不设置z-index值,那么默认值为auto,根据规范分层显示可得
1.若宿主z-index:auto,宿主和body属于同一个层叠上下文,根据分层图可得,before元素属于2.层叠级别为负值的后代层叠上下文而body的背景属于3常规流内非定位子元素组成的层,所以3在2的前面
2.若宿主z-index不为auto,宿主和body不属于同一个层叠上下文,before在宿主所处的层叠上下文里,而宿主的z-index为0或正值时属于层级6和7在3之前所以可见,但假如z-index为负值则又在3之后,又不可见了。
from css-secrets.
@hardfist 在项目也遇到了相似的问题,给宿主加z-index值就算比after也没有用。还是会覆盖宿主,最后根据你的回答,我把after设置负值就解决了
from css-secrets.
谢谢反馈。稍后会确认你提到的这个问题。
也欢迎其他读者参与讨论 😃
from css-secrets.
的确,亲测过,如楼主所说。
但问题貌似没这么简单,为啥在我测试下来(Chrome 51),只要给宿主加 z-index
,不管啥值,这个伪元素始终会叠加在宿主上。
所以书上这个 demo 所示方案的使用场景要打个问号。
from css-secrets.
@hardfist
谢谢提示,我稍后会整理到注解中。
from css-secrets.
这个最新的注解呢?关于使用z-index为负数时,出现在不同的位置。。对照书写毛玻璃这块代码遇到这个问题。。
from css-secrets.
Related Issues (20)
- [注解] [508] 现实中的文字效果
- [注解] [509] 环形文字
- [注解] [603] 自定义复选框
- 提交勘误 HOT 3
- [注解] [607] 交互式的图片对比控件
- 线性渐变 HOT 2
- 第59页勘误 HOT 2
- [注解] [705] 垂直居中
- [注解] [706] 紧贴底部的页脚
- [注解] [801] 缓动效果
- [注解] [802] 逐帧动画
- [注解] [806] 沿环形路径平移的动画 HOT 6
- [注解·加强版] 如何正确编写 Fallback 样式
- 复杂的背景图案实践中的疑问 HOT 5
- fill="%23fb3”,%23fb3怎么理解?fb3是颜色,23是什么? HOT 3
- p161:第 34 滚动提示,关于 `background-attachment` 代码问题 HOT 5
- [注解] [306] 简单的饼图
- 提交勘误 HOT 2
- p49页的蚂蚁行军边框问题 HOT 2
- 网站挂了,会修一下吗 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from css-secrets.