Positioning is tough to understand when you’re first starting out with CSS. Your choices are
Static is the default option and is positioned according to the normal page flow.
Relative item is positioned relative to itself, meaning you can move it up, down, left or right, based on where it would normally sit.
Absolute allows you to place an item anywhere on the page, and is the most misused positioning statement. The values you set for it will be relative to the last parent item with relative or absolute, and if there aren’t any, it defaults back to the html tag, allowing you to position it anywhere by declaring top left right or bottom values.
Fixed is positioned relative to the browser window, so an item will stay in place if a user has to scroll. Learning how to use positioning correctly is important, but shouldn’t be used excessively. I rarely use these at all in my stylesheets.
I have gone trough a lot of ways to horizontally and vertically center a DIV. Many of the code snippets had a Child DIV1 inside a Parent DIV2 to center the Child. They work perfect but I found a simpler way to center a single DIV trough CSS.
I am not sure if this is already known to all, but I experimented and came up with this simple CSS snippet.
Here is a visual representation of how this works:
Here is the CSS Snippet to be assigned to the DIV to be centered. The size of the DIV is 100 x 100 px ( same as the above example ).