Wrox Programmer Forums
|
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 December 19th, 2005, 04:40 PM
Registered User
 
Join Date: Oct 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Centering a box


I have a form within a box (<div>). The css statement below is the statement for the box.

#idClientLoginMainPage{ position: absolute; left: 0px; top: 0px; width: 700px; height: 550px; padding:10px; align:center; text-align:center }

I want to center the form in the 'ClientLoginMainPage'. The code above works fine in IE but it doesn't work in Nav or FF. The form moves to the left in both Nav and FF.

This css statement is the statment for the form:
#idSelectClientForm{ position: absolute; border:5px outset #C0C0C0; top: 50px; width: 350px; padding:15px; height:160px; text-align:center }

The website is http://www.cjmnew.cjmgraphics.com. Select 'Client Pages' from the top menu.

Although I have been working with websites for a while I've not really concered myself with crossbrowser problems. Well I need to now.

Thanks,


Terry Migliorino
[email protected]
 
Old December 20th, 2005, 01:58 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You site is asking for a login.
 
Old December 26th, 2005, 01:02 AM
Authorized User
 
Join Date: Jun 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to natmaster Send a message via AIM to natmaster Send a message via MSN to natmaster
Default

Works fine for me...

----------------------------
Aeon of Darkness MUD - Free Online Roleplaying Game
http://aeonofdarkness.com
 
Old December 28th, 2005, 09:22 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

First, there is no "align" property in CSS. Your website also doesn't show the document.

To get the form centered, do this:

Code:
#idClientLoginMainPage {
    position: absolute;
    left: 0;
    top: 0;  /* A unit of measurement is not required for zero length, zero is still zero regardless of the unit */
    width: 700px;
    height: 550px;
    padding: 10px;
    text-align: center;  /* You need this for IE 5.5, so it can stay, but that's not how you center a box
                            You'll need this for IE 6 too, if you're in quirks rendering mode.
                            You'll also find that all the text in all child elements is also centered
                            since this property is inherited */
}
I'm assuming that the thing you're trying to center is a <form> element with fixed dimensions inside of this "idClientLoginMainPage" element. If that is correct the CSS would look like this to center the <form>.

Code:
#idClientLoginMainPage form {
    width: 600px;             /* Just made that up. */
    border: 1px solid black;  /* So you can see the dimensions */
    margin: auto;             /* centers the form */
    text-align: left;         /* Reset the inheritence of text-align: center; */
}
If you're trying to center the absolutely positioned "#idClientLoginMainPage" element, that'd be done as follows:

Code:
#idClientLoginMainPage {
    position: absolute;
    left: 50%;           /* offset from the left by 50%, step 1 in centering */
    top: 0;
    width: 700px;        /* Give it a fixed width, step 2 in centering */
    height: 550px;
    padding: 10px;
    margin-left: -350px; /* Half the width to center, step 3 in centering */
    text-align: center;
}
HTH!

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
Centering an UL element within DIV keithc BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 April 4th, 2013 04:13 PM
Centering content Europom CSS Cascading Style Sheets 2 February 18th, 2008 06:25 AM
Centering elements in Firefox and IE akeyworth CSS Cascading Style Sheets 2 December 19th, 2007 12:02 AM
Not centering tul CSS Cascading Style Sheets 3 September 22nd, 2005 12:16 PM





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