Question:
How do i center my webpage on dreamweaver?
2012-07-24 23:35:11 UTC
Hey!


I spent 12 hours on trying to center my newly imported website. I'm gonna tell you what kind of webpage i have. So I opened a new document in photoshop cs6, 1280x1280. I designed a website. I sliced it, and exported it to a index.html and a image folder with the sliced buttons and such in it. Then I opened dreamweaver CS 5.5 ( I tryed CS3 too ). I opened my website in Dreamweaver, and the website was aligned to left. So I followed all kind of tutorials out there, but none of it works. My webpage does not get centered.

The closest thing i could do was to use margin:auto; and the website got centered, but then every single button and every single image got on top of each other like a list. I can upload my website here so you can see it: http://speedy.sh/GFNJU/site.rar

Please help me out :(
Four answers:
2012-07-25 01:38:13 UTC
absolutely terrible coding, so I have re-coded it for you



http://www.4shared.com/rar/jDDvuOfT/site.html
2012-07-25 04:38:01 UTC
Centering:



Centering an element requires setting a width that is less than 100%, using a proper document type and using the CSS property: margin: 0 auto; This is done in the CSS that styles the element. Example:



body {

width: 90%;

height: 600px; /* optional */

margin: 0 auto;

background: #fff url(path to non-tiled image) no-repeat center scroll;

}



Example as a Class:



.selector_name {

width: 90%;

height: 600px; /* optional */

margin: 0 auto;

background: #fff url(path to non-tiled image) no-repeat center scroll;

}



HTML for Class:
Content here




Example as an ID:



#selector_name {

width: 90%;

height: 600px; /* optional */

margin: 0 auto;

background: #fff url(path to non-tiled image) no-repeat center scroll;

}



HTML for Class:
Content here




Change parameters as you need. Set "#fff" to background color you want. Set "scroll" to "fixed" if you want page contents to scroll over background image. CSS was given for an image that does not tile. Doesn't have to be the body tag, but you should get the idea.



Ron
kyra
2016-07-23 14:42:25 UTC
Ensure you've particular the width of your field in css, then style margin-right: auto; and margin-left: auto; for the residences of the box as good and that will have to center it. Hope this helps...GL
Patz
2012-07-24 23:52:41 UTC
If you are using tables this script should work centering it for all browsers and screen sizes.



Try adding this script after the tag.







Then on the first tag change it to
.



That should center it.

This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...