1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Can't get layout to center!!

Discussion in 'CSS' started by jfontestad, Jan 28, 2007.

  1. #1
    Here's the layout I've been working on for the past few days now.

    http://fontestad.net/dev/layout-sliced.php

    I pretty much have the code where I want it, but I want to center the layout so that it always appears in the center of the browser.

    Can anyone help me out? I've tryed the margin 0 auto; i've tryed text-align center in the body tag, nothing seems to work.

    Can anyone point me in the right direction.

    I have a hunch on t what the problem is, but if i'm correct I'd need to recode the whole layout. :\
     
    jfontestad, Jan 28, 2007 IP
  2. prilep

    prilep Well-Known Member

    Messages:
    3,852
    Likes Received:
    228
    Best Answers:
    0
    Trophy Points:
    185
    #2
    Looks centered to me?? I'm not getting what you need.

    - Prilep :)
     
    prilep, Jan 28, 2007 IP
  3. SoftCloud

    SoftCloud Well-Known Member

    Messages:
    1,060
    Likes Received:
    28
    Best Answers:
    2
    Trophy Points:
    120
    #3
    It's centered for me too (firefox 2)
     
    SoftCloud, Jan 28, 2007 IP
  4. jared

    jared Peon

    Messages:
    231
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    it is not centered for me and I am using the latest FF.

    I think the problem is you have your margins set as a style of the body. This is not the way you want to center a site. Remove that.

    What you want to do is create a container div, place the site inside that, and then center it.

    So it would be like
    
    <div id="container">
       the rest of your site here
    </div>
    
    */ the css would be : */
    
    #container {
     width: 760px; */ or however wide your page will be */
     margin: 0 auto; */ this will center the container div and everything inside */
    }
    
    Code (markup):
    cheers
     
    jared, Jan 28, 2007 IP
  5. jfontestad

    jfontestad Well-Known Member

    Messages:
    1,236
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    148
    #5
    It's centered for all resolutions up to 1024*768

    I'm looking at it on 1400*900 and also on 1280*1024.

    :\

    jared I've tryed that already. But thanks.
     
    jfontestad, Jan 28, 2007 IP
  6. jared

    jared Peon

    Messages:
    231
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well I actually looked at your css. It is because you sliced it up using ImageReady and everything is absolutely positioned. You need to have some one code it by hand using correct markup (aka not just positioning everything absolute). Not to mention 1000px wide is pretty unconventional.

    Alternately you can use kind of a "work around" for now that will center it although I don't really recommend css hacks like this.

    You can set you table1 div to look like
    
    #Table_01 {
    	position:absolute;
    	left:50%;
    	width:1000px;
    	margin-left: -500px;
    	font-family: Trebuchet MS, Tahoma, Helvetica, sans-serif;
    }
    
    Code (markup):
    and that should center it

    cheers
     
    jared, Jan 28, 2007 IP
    jfontestad likes this.
  7. jfontestad

    jfontestad Well-Known Member

    Messages:
    1,236
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    148
    #7
    Green rep for you Jared. Worked like a charm.

    How much do you think someone would charge to properly code this css?

    I may do that, but i'm on a LOW LOW budget...

    struggling to pay my bills as is.... and if I can get by with the design how it is now, i may stick with it.

    another thing that you can possibly help me with...

    the affiliates menu appears fine in IE, but in firefox it's all messed up..
    any ideas ?
     
    jfontestad, Jan 28, 2007 IP
  8. duilen

    duilen Active Member

    Messages:
    354
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    58
    #8
    Check that in 800x600 now. 100px from your left and right edges should be cropped off.
     
    duilen, Jan 29, 2007 IP
  9. jfontestad

    jfontestad Well-Known Member

    Messages:
    1,236
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    148
    #9
    Well until i can get some $$$ and have a professional code it, it may have to stay this way.

    87+ percent of my traffic is AT LEAST 1024*768 resolution, only ~ 13% has 800*600 or less.

    But none the less thanks for the heads up. :\ I'll see if there is anything I can do to fix it in the mean time.
     
    jfontestad, Jan 29, 2007 IP
  10. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #10
    A couple of things:

    Using absolute positioning for the over all layout is likely the worst way to do things. But, that, or tables, is all a wysiwyg editor/layout maker can do. Learn to write html and css; it's not rocket science.

    Make your outer wrapper div {position: relative; width: xx (whatever you need); margin: 0 auto;}. Be sure you have a complete and proper DTD, so IE will act half-assed sane. That will center the document in the viewport, where possible. Overflow will simply be scrolled.

    Don't put too much stock in resolutions. That's screen size. Users in the know, with large monitors, do not waste screen real estate by running applications maximized. Especially not browsers, editors or word processors. The browser here is only 800px wide in a 1280px monitor because that provides a comfortable width column for reading plus a sidebar. Editors need only be 80 fixed-width characters wide. Same with the Xterm. The word processor needn't be wider than a letter or A4 sheet of paper&#8212;about 800&#8211;900px, oddly enough. All those huge screens don't mean a thing. What size is the application window?

    cheers,

    gary
     
    kk5st, Jan 29, 2007 IP
  11. Ginger Ninja

    Ginger Ninja Guest

    Messages:
    161
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #11
    #wrapper { margin:0 auto; }
    Code (markup):
    This will center any DIV with the ID of wrapper. It wont work with classes unless you use;

    .wrapper { margin:0 auto; display:block; }
    Code (markup):
     
    Ginger Ninja, Jan 30, 2007 IP
    jfontestad likes this.
  12. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #12
    The suggestion I gave,
    
    #wrapper {
        margin: 0 auto;
        position: relative;
        width: 950px; /*nominal value*/
    Code (markup):
    gives all the absolute positioned elements a positional reference, {position: relative;}. That's so they will 'move' with the outer container. The width is required because otherwise the div will simply take the width of the browser window, and the margin property for centering would be meaningless. The width property also satisfies IE's silly requirement that the positional reference have the property "hasLayout".

    cheers,

    gary
     
    kk5st, Jan 30, 2007 IP
    jfontestad likes this.
  13. jfontestad

    jfontestad Well-Known Member

    Messages:
    1,236
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    148
    #13
    Indeed.

    kk5st: Green rep. I've implemented it and works great. Even fixed a few other problems I was seeing in FF.
     
    jfontestad, Jan 30, 2007 IP