navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Centering DIvs on a page

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> Cascading Style Sheets >> Centering DIvs on a page
Page: [1]
 
Stuey

 

Posts: 203
From: Dudley West Midlands, United Kingdom
Status: offline

 
Centering DIvs on a page - 9/23/2003 5:40:52   
How do I center a div on a page I can center the text within the page?

STuart

_____________________________

Stuart Steele - www.stuweb.co.uk
Donkey

 

Posts: 3887
Joined: 11/13/2001
From: Blackfield United Kingdom
Status: online

 
RE: Centering DIvs on a page - 9/23/2003 19:17:22   
This may be totally the wrong way but it should work.

I would first of all design the positioning based on a 780 x 580 px screen size.
Make the width of the div the width you want in pixels and position it (absolutely) so that the div is central.
e.g if the div should be 200 pixels wide use
left: 190px;
width: 200px;
Then set all your other positioning again using absolute pixel values.
When you are happy that it is all in the right place, go right through your style sheet and change the pixel values into percentages based on the 780 x 580 screen size.
e.g. in the example above the width of the div becomes 34% and the left value 33%.

Alternatively if you want to just centralise the contents of the div across the page you could make the width 100%.

There may well be a better way but I have used this method on a test page I am playing with and it works for me.

ps. At a quick glance I thought your avatar was the loch less monster and it's shadow untill I looked more closely. I wondered what Nessie was doing down there in the Black Country:)

_____________________________

:)

I have a higher and grander standard of principle than George Washington. He could not lie; I can, but I won't.
Samuel Clemens

(in reply to Stuey)
Gil

 

Posts: 7533
From: North Carolina, USA
Status: offline

 
RE: Centering DIvs on a page - 9/23/2003 19:53:01   
<div ALIGN="center">

_____________________________

Gil Harvey, 1947-2004

(in reply to Stuey)
Page:   [1]

All Forums >> Web Development >> Cascading Style Sheets >> Centering DIvs on a page
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts