Home  >  Article  >  Web Front-end  >  How to set the relative position of div in css without occupying the position? _html/css_WEB-ITnose

How to set the relative position of div in css without occupying the position? _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:03:464496browse

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!


Reply to discussion (solution)

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;
}

Statement:
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