Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    centering (the usual)

    hello peoples,

    as usual its the old centering issue that (for me anyway) plagues my website design life......

    i'm trying to center the contact info box on this page.....

    http://gandhiproductions.herobo.com/...4/contact.html

    it need to be dynamic, so it stays centered if the window is resized....

    i've tried finding info on the net about this but nothing works....

    help anyone.... any help?

    thank you

    Gandhi

  • #2
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,208
    Thanks
    7
    Thanked 268 Times in 267 Posts
    To center an object, it needs a width (presumably smaller than the object it's being centered within), it needs auto left and right margins, and the document needs a doctype. The only thing you're missing is the auto margins.

    Dave

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello evilgandhi,
    You have more than just a centering problem. You have some divitis there, you don't follow the box model and you float a full width element. Look at these changes to your CSS -
    Code:
    #centercontactbox{
    		/*height:270px;
    	width:400px;*/
    width: 410px;
    margin: 0 auto;
    clear: both;}
    
    #contactbox{
    	/*height:270px;
    	float:left;*/
    	width:400px;
    	padding:5px;
    overflow: auto;
    	background:#6194aa;
    	text-align:center;
    }
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •