Home > Article > Web Front-end > How to set the relative position of div in css without occupying the position? _html/css_WEB-ITnose
For example
#box_relative {
position: relative;
left: 30px;
top: 20px;
}
The space it occupies is still retained, how? Let it not take up position, and can achieve relative positioning.
What I want to achieve is the position of a certain div relative to an element, but without occupying the position.
Thanks in advance!
Position:absolute (child) and position: relative (parent) are used together
is what is called Relative positioning
Are you considering the level issue?
#box_relative{
position: absolute;
left: 30px;
top: 20px;
}
You can set it to adjacent boxes It is relative positioning and does not deviate from the standard. Then add this box inside
#box_relative {
position: absolute;
left: 30px;
top: 20px;
}