CSS 1.css介绍 css指的是层叠样式表(cascading style sheets) 官方文档:https://www.w3school.com.cn/css/index.asp为什么需要c
顺晟科技
2021-08-27 11:44:06
193
position 有五个值:static、relative、absolute、fixed、inherit。
是默认值。就是按正常的布局流从上到下从左到右布局,平常我们做网页时,没有指定 position,也就表示使用 static。
没有脱离布局流,此时可以使用 top、right、bottom、left 属性。
relative 是相对位置,指相对于元素的 position 为 static 时的位置:
使用 relative 之后:
脱离布局流,此时可以使用 top、right、bottom、left,但这些属性不再是相对于 static 时的位置,而是相对于 containing block 的,相对于其边框内边缘的,而不是其 padding 内边缘。也就是相对于最近的 position不是static的块级祖先元素盒子进行定位。
使用 absolute 之后:
它的模式与 absolute 相同,不过无论怎么拖动滚动条,它始终固定在屏幕的指定位置。在 IE6 中不支持这个属性;在 IE7 中支持这个属性但需要指明 DOCTYPE;Firefox 等浏览器支持这个属性。
top、right、bottom、left 属性指相对于视口的。
继续父元素的 position 值。
如何确定包含块:
确定包含块的过程完全依赖于这个包含块的 position
属性:
static
或 relative
的话,包含块就是由它的最近的祖先块元素(比如说inline-block, block 或 list-item元素)或格式化上下文(比如说 a table container, flex container, grid container, or the block container itself)的内容区的边缘组成的。fixed
, absolute
, relative
, or sticky
)的祖先元素的内边距区的边缘组成的。transform
or perspective
value other than none
will-change
value of transform
or perspective
filter
value other than none
or a will-change
value of filter
(only works on Firefox).注意: 根元素(<html>)所在的包含块是一个被称为初始包含块的矩形。It has the dimensions of the viewport (for continuous media) or the page area (for paged media).
如上所述,如果某些属性被赋予一个百分值的话,它的计算值是由这个元素的包含块计算而来的。这些属性包括盒模型属性和偏移属性:
09
2022-11
09
2022-11
09
2022-11
09
2022-11
19
2022-10
19
2022-10