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 9 of 9
  1. #1
    New Coder
    Join Date
    Jan 2008
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I get these DIVs to center?

    Hey guys

    This is driving me nuts - any ideras how to get the artist boxes to center align?

    http://www.popbeatblues.com.au/solos.php

    Cheers

    Shaun

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Location
    UK
    Posts
    151
    Thanks
    9
    Thanked 2 Times in 2 Posts
    Code:
    <div align="center">Content in here</div>

  • #3
    New Coder
    Join Date
    Jan 2008
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's what I thought too Tyanque, but it doesn't center the content. Any idea why not?

    Cheers

    Shaun

  • #4
    Regular Coder
    Join Date
    Mar 2007
    Location
    UK
    Posts
    151
    Thanks
    9
    Thanked 2 Times in 2 Posts
    ive looked at your code, put this

    Code:
    <div align="centre">
    before

    Code:
    <div id="acts_wrapper">
    then add another </div> after the acts_wrapper closing tag, should work

  • #5
    New Coder
    Join Date
    Jan 2008
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks mate, but still no joy - bizarre. I can't see anything else in the code that could be interfering with it.

  • #6
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    I'de put them into a table. Then its easy. Just because tables shouldn't be used for layouts doesn't mean they shouldn't be used...

    -Adam
    Why not thank me?

    http://adamsworld.name

  • #7
    New Coder
    Join Date
    Jan 2008
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow - even that didn't work. I think it may have something to do with the float:left I have on the boxes, but they need it to display correctly.

  • #8
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    You need to have 1 <td> for each of your boxes

    -Adam
    Why not thank me?

    http://adamsworld.name

  • #9
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    No.......All the above suggestions are incorrect!
    align="center" is depreciated and you will get errors on validation.
    table is not required to center this. Remove it.

    First of all make sure that all your div having class="box" are correctly nested in the parent div #acts_wrapper (I see the last one is placed inside the 3rd one)

    You can easily center any block level element inside another block level element by giving margin:0 auto; to the inner element(IE may require an additional style to the parent element text-align:center;).
    To see the effect you have to give a smaller width to the inner element to that of outer one.

    Here, in your case, you have placed well the 4 elements to be centered inside a container #acts_wrapper. Your aim is to give a width to this element and center this container inside its parent.
    Width can be calculated as 4*110+4*26, where 110 is the width of each box and 26 is the margin-right.
    But the last element does not require that right margin. So give a style="margin-right:0" to the last one and reduce one 26 from the above width(width:518px; right?).

    good luck!
    Last edited by abduraooft; 02-17-2008 at 01:01 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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