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 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Div and Content Placement

    Before I begin let me just say that I have tried everything I could from google to do this and nothing worked for me.

    I am trying to center my div on the screen, yet have the content in that div right justified.

    I use,
    PHP Code:
    #titles {
      
    floatleft;
      
    text-align:right;
      
    background-color#dddddd;
      
    margin-leftauto;
      
    margin-rightauto;

    for the division.

    I added a container that uses the below and nothing still
    PHP Code:
    #form {
      
    floatleft;
      
    width100%;
      
    text-aligncenter;
      
    margin0 auto;

    Any help would be appriciated.

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,748
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    Hello JimmyS,
    The way you have it now, your not really giving your content anything to center on because you have either width: 100% or no width set at all.
    Try it like this...
    Code:
     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <style type="text/css">
    body {
    	text-align: center;
    	background-color: #CCCCCC;
    }
    #form {
    	width: 600px;
    	text-align: center;
    	margin: 0 auto;
    	background-color: #FFFFCC;
    }  
    #titles { 
    	width: 300px;
      	float: left; 
      	text-align:right; 
      	background-color: #dddddd; 
    }  
    </style>
    </head>
    <body>
    <div id="form">
    <div id="titles">
    <p>some text here</p>
    </div>
    </div>
    </body>
    </html>
    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

  • #3
    New Coder
    Join Date
    Oct 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I just kinda assumed if you didn't set the width that the width was automaticlly determined.

    Anyway, that worked, thanks for the help boss.

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,748
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    I just kinda assumed if you didn't set the width that the width was automaticlly determined.
    It is. It automatically takes up all the space available.
    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


  •  

    Posting Permissions

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