This is probably an easy task for you guys, but I'm trying to understand the default behavior of elements with absolute positioning. I read that an element with absolute positioning is removed from the document stream, which means that the surrounding elements behave as if they were not there at all.
Now by default we place elements with absolute positioning. Shouldn't it appear in the upper left corner of the parent with position: relative;?
I created an example of what I mean on JSFiddle
This example consists of the following markup:
#top_header_nav {
position: relative;
display: table;
margin: 0 auto;
}
ul {
padding: 0;
margin-left: 15px;
margin-right: 15px;
}
li,
img,
ul {
display: inline-block;
}
img {
margin: 10px 30px 0px 30px;
}
li {
font-size: 24px;
margin-left: 30px;
}
li:first-child {
margin-left: 0px;
}
<nav id="top_header_nav">
<ul>
<li>Menu item 1</li>
<li>Menu item 2</li>
</ul>
<img id="top_header_nav-logo" src="http://i1202.photobucket.com/albums/bb380/blogbiztutor/Blogger/Button/bth_google-logo.gif"></img>
<ul>
<li>Menu item 3</li>
<li>Menu item 4</li>
</ul>
</nav>
Run codeHide result, - , . position: absolute; , ( ), - , ul. , , , .
, left: 0;, ? .