DIV in "ceter/middle"

Discussion in 'CSS' started by HPA, Nov 21, 2007.

  1. #1
    The title explains it all. I want to create a tableless template. So I need a simple code to put the div in the middle.


    Thanks,
    ~HPA
     
    HPA, Nov 21, 2007 IP
  2. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #2
    horizontal auto margins will do that.

     
    soulscratch, Nov 21, 2007 IP
  3. HPA

    HPA Notable Member

    Messages:
    1,335
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    205
    #3
    Thanks, but now all text is in the middle... Is there anything, we could do about it?
     
    HPA, Nov 21, 2007 IP
  4. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #4
    HPA, the best you're going to be able to do is provide a graphical mockup of how you want the design to look (simple boxes with the type of content listed inside will be best) so that someone who knows what they're really doing (read: deathshaodw, Stomme poes, soulscratch, myself, etc) can show you how to code it the best way.
     
    Dan Schulz, Nov 21, 2007 IP
  5. Crimsonc

    Crimsonc Peon

    Messages:
    616
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    in fear of feeling soulscratch's wrath, can we see the page?
     
    Crimsonc, Nov 21, 2007 IP
  6. HPA

    HPA Notable Member

    Messages:
    1,335
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    205
    #6
    The current width of my table is 732px. But I want to create a tableless page. But i still want my contents to be in the middle...
     
    HPA, Nov 21, 2007 IP
  7. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Then what you need to do is create a container DIV that will hold everything in the page, give it a width and then use margin: 0 auto; to center the page (but not its contents).
     
    Dan Schulz, Nov 21, 2007 IP
  8. Crimsonc

    Crimsonc Peon

    Messages:
    616
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #8
    okay to get your content in the middle put everything in a 'wrapper' div and give it this property:

    margin: auto;
     
    Crimsonc, Nov 21, 2007 IP
  9. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #9
    And a width, Crimsonc. :)
     
    Dan Schulz, Nov 21, 2007 IP
  10. HPA

    HPA Notable Member

    Messages:
    1,335
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    205
    #10
    Yeah, I've done it, but the problem is still there...
    My text get's in the middle...
     
    HPA, Nov 21, 2007 IP
  11. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #11
    Link to page ?. A text-align:left; may solve it.. I'm getting the hint that you're not even using a doctype.
     
    soulscratch, Nov 21, 2007 IP
  12. HPA

    HPA Notable Member

    Messages:
    1,335
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    205
    #12
    I'm using a doctype....
    I'm working on it, offline...

    Okay i'll try to add text-align: left;

    Problem solved, thanks so much!
     
    HPA, Nov 21, 2007 IP