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.

Width percentages help!

Discussion in 'CSS' started by Audentio, Dec 11, 2007.

  1. #1
    Hey there!

    I have been coding using divs only for almost a year now and I still seem to have trouble every now and then. One thing I never really learned was how to center things by percentages. In a table, this is how it'd look:

    <table cellpadding="0" width="100%" cellspacing="0" align="center" border="0">
        <tr>
            <td with="25%" align="center">
            Cell 1
            </td>
            <td with="25%" align="center">
            Cell 2
            </td>
            <td with="25%" align="center">
            Cell 3
            </td>
            <td with="25%" align="center">
            Cell 4
            </td>
        </tr>
    </table>
    
    Code (markup):
    Can someone explain how I can do this same thing in css? Rep and I may pay if it works a charm ;).
    SEMrush
     
    Audentio, Dec 11, 2007 IP
    SEMrush
  2. NsaneNoob

    NsaneNoob Peon

    Messages:
    2,103
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think it is something like this:

    centered {
    position: fixed;
    top: 50%;
    left: 50%;
    }
     
    NsaneNoob, Dec 11, 2007 IP
    Audentio likes this.
  3. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    105
    #3
    Set a width (less than 100% in percentages) and margin:0 auto;
     
    soulscratch, Dec 11, 2007 IP
    Audentio likes this.
  4. Audentio

    Audentio Well-Known Member

    Messages:
    424
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Thanks for your help you guys, repped you both. :) Ill try this now.
     
    Audentio, Dec 11, 2007 IP