css 各种百分比的指向

163 阅读1分钟
相对于于父级宽度的:

max-width、min-width、width、left、right、text-indent、padding、margin、grid-template-columns、grid-auto-columns、column-gap 等;



相对于父级高度的:

max-height、min-height、height、top、bottom、grid-template-rows、grid-auto-rows、row-gap 等;



相对于自身宽高的:

border-radius、background-size、border-image-width、transform: translate()、transform-origin、zoom、clip-path 等;



相对于主轴长度的:

flex-basis 等;



相对于继承字号的:

font-size 等;



相对于自身字号的:

line-height 等;



相对于行高的:

vertical-align 等;



如果自身设置 position: absolute,“父级”指:相对于离它最近的那个 position 不为 static 的祖先元素,如果没有这样的元素,则相对于视口

如果自身设置 position: fixed,“父级”指视口(父级不存在 transform 为非 none 值的情况下)。
---------------------
作者:Kirito丷
来源:CSDN
原文:blog.csdn.net/qq_33576343…
版权声明:本文为博主原创文章,转载请附上博文链接!