Results 1 to 4 of 4

Thread: centering 3 tables on a page

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default centering 3 tables on a page

    I have 3 tables of variable widths depending on the text used in each column. the tables are side by side. I want to horizontally center the three tables on a page.

    I tried placing the tables in a div and set the left and right margins to auto. The problem with this method was that the tables could not be floated and removing the floats stacked the tables.

    I can't set the width of the div because the tables have variable widths.

    Any ideas?
    Last edited by james438; 01-04-2012 at 03:12 AM. Reason: reworded for clarification
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    Jan 2009
    Location
    NH
    Posts
    675
    Thanks
    98
    Thanked 26 Times in 26 Posts

    Default

    where is your code or page it's on?

    edit, I misread, though it was one table with 3 columns

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Got it.

    I need to use the following css:

    Code:
    <style type="text/css">
    .a1{left:50%;float:left;position:relative;}
    .a2{float:left;left:-50%;position:relative;}
    </style>
    First, there is the parent div with a class of 'a1'. The three tables are placed in their own divs inside the parent div and each has a class of 'a2'.

    I got the tip from: http://pmob.co.uk/pob/centred-float.htm.
    To choose the lesser of two evils is still to choose evil. My personal site

  4. #4
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    After using the above css I have created a page [link removed], which is a sample of a page I use in my admin panel where I can view and edit the various tags used on my website.

    When you view the page you can see that the the page scrolls a little to the right. It should not do this. Any ideas on how I can fix this or what is causing it? I notice that decreasing the number of tags seems to fix this, but that doesn't make much sense to me.

    Most likely I will delete the test page when this problem is figured out.
    Last edited by james438; 01-19-2012 at 12:00 AM. Reason: removed link. Still working on it though.
    To choose the lesser of two evils is still to choose evil. My personal site

Bookmarks

Posting Permissions

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