Introduction to relative positioning and absolute positioning in CSS

黄舟
Release: 2017-05-27 13:53:19
Original
1409 people have browsed it

1. Generally, if we do not set position for an element, the default is static. At this time, the element is not positioned, and offset attributes such as left/right have no effect.

2.position:relative (relative positioning)

If set to relative positioning, you can configure the left/right offsets relative to the original position of the element , and the original position still occupies the space of the document flow, and the offset will not crowd out other elements,So if overlap occurs, the stacking order can be set through z-index.

3.position:absolute

When an element is set to absolute positioning, it does not occupy space in the document flow and will float. Different from relative positioning, absolute positioning will delete the space of the original position in the document flow. Positioningis positioned through the parent element that is not static. (If the parent element is static, then find the parent element of the parent element. Element, go to the upper level to find).

The above is the detailed content of Introduction to relative positioning and absolute positioning in CSS. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!