If you’re new to CSS, you might be wondering why is it that when you create a container they all stick to the left side of the page:
This is the default layout, and years back when most people had very small screens, these left-side layouts sufficed. These though, it is wise to stick to a centralized layout because people are using all kinds of screen sizes so it’s the recommended layout to use for easy browsing.
To achieve a centralized layout on CSS:
Your code should look a bit like this:
#container {
margin: 0 auto;
text-align: left;
width: 1000px;
position: relative;
}
‘Margin-zero-auto’ centralizes your #container, ‘text-align-left’ ensures that your content begins from the left side, ‘width’ controls the width of your container (this can also be set in percentage, which allows fluid width relative to the browser canvas), and ‘position-relative’ ensures that any div with the absolute position property is positioned relative to the container.
So you’ve got yourself something pretty solid with that.
Related posts:



















