๐นposition
โฑ๐ง under construction
่จญๅฎไบ position
็ๅ
็ด ็จฑ็บๅฎไฝๅ
็ด (positioned element) ใ
relative
๏ผๆไพๅญๅ ็ด ๆฐ็ๅ่ๅบงๆจ๏ผไฝ่ชๅทฑไฝ็ฝฎไธ่ฎใabsolute
๏ผๅ่ๆ่ฟๅฎไฝ็ถๅ ็ด ๏ผๅฐ่ชๅทฑๅฎไฝๅจ็ตๅฐไฝ็ฝฎไธใfixed
๏ผsticky
๏ผstatic
๏ผ
static
ๆฏ้ ่จญๅฑฌๆง๏ผไธๆ่ขซๅญๅ ็ด ่ฆ็บๆฏใๅฎไฝ็ถๅ ็ด ใ ใ
By default, any positioned element appears in front of any non-positioned elements.
coordinates of fixed elements are relative to the viewport.
coordinates of absolutely positioned elements are relative to the document.
If none of the absolutely positioned elementโs ancestors are positioned, then the element will be positioned based on the initial containing block - an area with dimensions equal to the viewport size, anchored at the top of the page.
By setting top/bottom, left/right , you also implicitly define the width / height of the (fixed and absolutely, but not relatively positioned) element.
Unlike fixed and absolute positioning, you cannot use top/bottom, left/right to change the size of a relatively positioned element.
can use top or bottom, but not both (bottom will be ignored).
can use left or right, but not both (right will be ignored).
z-index
z-index only works on positioned elements.
applying a z-index to a positioned element establishes a stacking context.
Elements with a negative z-index appear behind static elements.
Last updated