Home > Article > Web Front-end > What are the layout methods of HTML web pages?
The position of the element is specified through the "left", "top", "right" and "bottom" attributes. Absolutely positioned elements are out of standard flow. Does not take up space in the standard stream. Absolutely positioned elements do not distinguish between block-level elements/inline elements/inline block-level elements. If an absolutely positioned element uses the body as the reference point, then it actually uses the width and height of the first screen of the web page as the reference point, rather than the width and height of the entire web page. The positioned element will scroll as the page scrolls. When a box is absolutely positioned, you cannot use margin: 0 auto; to center the box itself, you can use left: 50%; margin-left: - set the element width to half px to center;2>
The position of the element is specified through the "left", "top", "right" and "bottom" attributes. Fixed-positioned elements are separated from the standard flow and will not occupy space in the standard flow. That can be understood as being deleted from the standard stream. Fixed positioned elements do not distinguish between block-level elements/inline elements/inline block-level elements. E6 and lower versions do not support fixed positioning and can be solved using javascript.3>
When using relative positioning, no matter whether the element is moved or not, the element still occupies the original space, so moving the element will cause it to cover other boxes. In relative positioning, only one positioning attribute can be used in the same direction. Relative positioning does not deviate from the standard flow, so distinguish block-level elements/inline elements/inline block-level elements in relative positioning. And because relatively positioned elements will occupy positions in the standard flow, setting attributes such as margin/padding for relatively positioned elements will affect the layout of the standard flow.5>
There is no center alignment in the floating stream, and there is no center value. Margin: 0 auto cannot be used in floating streams. In the floating stream, block-level elements/inline elements/inline block-level elements are not distinguished. Whether it is block-level elements/inline elements/inline block-level elements, they can be typeset horizontally. Both width and height can be set. When an element is set to float, it will be separated from the standard stream (off-standard) and will not occupy space in the standard stream. If the following element is not floating at this time, then this element will cover the following element at this time.1>
The above is the detailed content of What are the layout methods of HTML web pages?. For more information, please follow other related articles on the PHP Chinese website!