Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > CSS > CSS Cascading Style Sheets
|
CSS Cascading Style Sheets All issues relating to Cascading Style Sheets (CSS).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the CSS Cascading Style Sheets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 30th, 2005, 08:19 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 137
Thanks: 0
Thanked 0 Times in 0 Posts
Default DIV - Centre Positioning Prob

Hi

I'm having to create tabless layouts using CSS / XHTML Transitional, and am kinda new to CSS positionings since having come from a Macromedia Dreamweaver / Fireworks background.

Basically I have a design layout that is broken down into a number of <DIV> which are stacked onto each other. Could somebody advise what is the best approach on centering in CSS. Bacially want to acheive a layout whereby the design is always central and remaining left and right widths of blank space are of equal widths.

Whats the best approach?

Gaz
__________________
Gaz
 
Old May 30th, 2005, 08:42 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

text is centered with text-center. Blocks (<div>) are centered with margin: auto; (where the auto keyword is the value for the left and right margins, it does nothing for the top and bottom margins). Explorer 5.5 and Explorer 6 quirks mode do not support margin: auto;, but Explorer 6 standards mode does. In Explorer 5.5 and 6, you can use the text-align property to center blocks, but take care as this property is inherited, but that is easy to overcome.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old May 30th, 2005, 08:56 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 137
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Rich

Thanks for the suggestion. That sounds it might do the trick. The problem I have is that I have used tables for layout for so long
it's a habbit that takes a while to get out of.

I guess what I was wondering was, say I declare each BLOCK <div> to be
a pixel width of 600. And then use percentages for the left and right
margin of each block? Would I get the same desired effect? I have give it ago but think I have confused myself a little

Gaz
 
Old June 5th, 2005, 09:23 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

> And then use percentages for the left and right margin of each block?

I'm not sure, I've never tried it. Why not give it a go and report your results? If all you're trying to do is center the block why not use auto margins? Don't forget that the auto margin has to be applied to the block you want to center and not the containing block, which is where it differs from the align attribute of HTML, text-align in Explorer OTOH must be applied to the containing element.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design





Similar Threads
Thread Thread Starter Forum Replies Last Post
Positioning Div over specific table cell pjmair HTML Code Clinic 4 May 8th, 2009 02:19 PM
Contact Centre Softwares carollinamosbah Flash (all versions) 0 June 25th, 2008 07:36 AM
Help with positioning a DIV using XSLT and XML skidmerc XSLT 3 May 2nd, 2008 06:45 AM
testing div positioning in different screen sizes crmpicco CSS Cascading Style Sheets 1 February 11th, 2008 05:02 AM
Pure CSS Positioning Prob socoolbrewster CSS Cascading Style Sheets 4 September 7th, 2005 08:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.