![]() |
Div Postitioning
Hi
I am currently building a website as part of my FinalMajor project for college.I have laid out all the divs where i want them all to be however i would like to position them all in the center of the browser instead of the left where they are now. Is there a simple piece of code i can use to do this? I am using a an external CSS sheets as well if that helps. Any help is greatly appreciated Adam |
Hello designer21,
To center an element you need three things:
Typically, for an entire site, you would center a containing element and place your divs inside that. |
What Excavator said is exactly right.
Just follow steps one and two and for step three just type margin-left: auto; margin-right: auto; in your css |
Quote:
Code:
Code:
|
I always like to supply valid code when providing examples to a newbie that may have no idea about DocTypes or how an .html document is laid out. We can always address linked/attached CSS later if needed.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
Quote:
|
Thanks for your help guys, for some reason when i tried putting a wrapper div it didn't center it with thhe margins set to auto howeer when i did the divs seperately they did, thanks again
|
| All times are GMT +1. The time now is 04:28 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.