We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
对普通元素设置transform属性,会将普通元素提升为一个新的层叠上下文:
transform
提升该元素的垂直地位,可以理解成z-index变大
绿色块的元素顺序在红框后面,红框设有margin-left:-20px ,正常应该是绿块盖住红框,设置tranform则红框会盖住绿块。
margin-left:-20px
改变子元素的定位基准,fixed定位会相对于设置transform的祖先元素定位,如果absolute基于transform的祖先元素定位,那么会忽略上外边距。
fixed
absolute
浅蓝色块(fixed定位)本身应当一直离窗口30px,设置tranform则发现变成离红框的距离变成了30px,同时蓝色块(absolute定位)也下移了30px。
使绝对定位(absolute)的子元素受父元素overflow:hidden的作用。(ps:绝对定位(absolute)的子元素宽度大于父元素,如果父容器的定位是static,也就是默认时,overflow:hidden无效)
overflow:hidden
static
蓝色块一开始不受父元素的overflow作用,设置tranform则发现受父元素overflow影响。
overflow
tranform
预览链接: 其他前端有趣的例子和坑合集:https://github.com/wqhui/blog
设置完transform属性后,浅蓝色块相当于红框去定位;蓝色块也相当于红框去定位;红框直接盖过了绿色块。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
对普通元素设置
transform
属性,会将普通元素提升为一个新的层叠上下文:绿色块的元素顺序在红框后面,红框设有
margin-left:-20px
,正常应该是绿块盖住红框,设置tranform则红框会盖住绿块。浅蓝色块(
fixed
定位)本身应当一直离窗口30px,设置tranform则发现变成离红框的距离变成了30px,同时蓝色块(absolute
定位)也下移了30px。蓝色块一开始不受父元素的
overflow
作用,设置tranform
则发现受父元素overflow
影响。预览链接:
其他前端有趣的例子和坑合集:https://github.com/wqhui/blog
设置完transform属性后,浅蓝色块相当于红框去定位;蓝色块也相当于红框去定位;红框直接盖过了绿色块。
The text was updated successfully, but these errors were encountered: