Centering Your Layout
You are here: Home > Visitor > Tutorials > Centering Your Layout
Having a centered layout kinda up the ‘prestige’ of your layout. It looks nice and lets your visitors know you can code your layouts. I am always on the look out for centered layouts. When I see one aligned to the left or right I wonder if they did that on purpose or just don’t know how to center.
Centering is really, really, really, easy. It just has to be explained. Here’s how to do it:
Get everything that you want to be centered and put this in a div. This also referred to as ‘wrapping in a div’. You might see this kind of wrap when you want to keep your sidebar or footer next to your content.
This is the css code (you can just add the new css to your existing css for this div [if you have a div already]):
#divname {
margin-right: auto;
margin-left: auto;
}
This will create an equal margin or the left and right sides of the div.