My question is: If I am in a situation where the positioning relativeand absoluteshould have the same result (for example, if I use this position to the element div, which is the only element on the page), and I set a specific width for my element, why the contents divdisplayed po- different ways, and is there a way to fix this.
A simple example should help to understand:
Usage position: relative;:
.test-border {
width: 800px;
position: relative;
border-left: 3px solid #DFDFDF;
}
<div class="test-border">
<ul>
<li>content</li>
<li>content</li>
<li>content</li>
<li>content</li>
<li>content</li>
<li>content</li>
</ul>
</div>
Run codeHide resultUsage position: absolute;:
.test-border {
width: 800px;
position: absolute;
border-left: 3px solid #DFDFDF;
}
<div class="test-border">
<ul>
<li>content</li>
<li>content</li>
<li>content</li>
<li>content</li>
<li>content</li>
<li>content</li>
</ul>
</div>
Run codeHide resultIf you view this page in a browser and replace it with an absolute relative, you will see that the list is not located in the same way when the container is absolute/ relative. This is true for Firefox and Chrome.
relative/absolute , , - , ;-)...
, - ?