How to make a "container" div a certain size as well as centre it.

X

xxfiredragonxx

If you are all wondering how to create a centred div with a certain
size, as well as a margin, the way I do it is like this:

#container {
width: 775px;
background: #fff;
margin: 1em auto;
text-align: left;
}

the WIDTH is for the size of the actual div
background is so then it'll come up at front of the background.
MARGIN is how you center it. AUTO automatically calculates the size of
the window and centres it in the page. 1em is how much space is
between the DIV and the page itself. You can set it to 0 if you want.
TEXT-ALIGN is just there to fix the text if something in the CSS has it
set to something like CENTER or RIGHT.

- Mark

P.S.This is just my own knowlege, it's not off of any website.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top