CSS xiangdui dingwei
- Previous page CSS dingwei guan shu
- Next page CSS jue dui dingwei
The element box set to relative positioning will offset a certain distance. The element still maintains its shape before it is positioned, and the space it originally occupied is still retained.
CSS xiangdui dingwei
Relative positioning is a very easy concept to grasp. If an element is relatively positioned, it will appear at its location. Then, by setting the vertical or horizontal position, this element can be moved 'relative to' its starting point.
If top is set to 20px, the box will be 20 pixels below the top of the original position. If left is set to 30 pixels, a space of 30 pixels will be created on the left of the element, which is to move the element to the right.
#box_relative { position: relative; left: 30px; top: 20px; }
As shown in the following figure:

Note that when using relative positioning, the element still occupies the original space, whether it is moved or not. Therefore, moving the element will cause it to cover other boxes.
CSS na tashi kara kai lixi
- Position: relative positioning
- This example shows how to position an element relative to its normal position.
- Previous page CSS dingwei guan shu
- Next page CSS jue dui dingwei