www.webdeveloper.com
Results 1 to 6 of 6

Thread: Center Page

  1. #1
    Join Date
    Sep 2009
    Posts
    51

    Center Page

    Hi,

    I have a web page with a form with a border on top, and under it a table with data.

    Is there a way in CSS to make sure that regardless of their size both the form and the table always appear in the middle of the browser window?
    I.e. the space to the right of either one should be the same as the space to the left.

    Thank you.

  2. #2
    Join Date
    May 2009
    Location
    Hampshire, UK
    Posts
    277
    give the table the property of:

    Code:
    margin: auto;
    Unless I have misunderstood you, that should work.

  3. #3
    Join Date
    Dec 2005
    Posts
    2,984
    This is assuming you mean 'center' instead of 'middle' - middle implies horizontally AND vertically centered (at least to me) which is a much trickier feat. Specifying margin: auto only works if the element is given an explicitly defined width.
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  4. #4
    Join Date
    Sep 2009
    Posts
    51

    Thanks

    margin: auto; helped in my case.
    Thanks a lot!

  5. #5
    Join Date
    May 2009
    Location
    Hampshire, UK
    Posts
    277
    Well what you are trying to do is possible but requires workarounds due to the fact that css does not offer vertical align for these elements.

    There are several workarounds you can try:

    The best way of doing it requires you to know the height of your element. Is there no way of you working this out?

    A very poor way of doing it would be to create a 1 cell table with width 100%, text-align: center and vertical-align: middle;

    There are likely to be some solutions around the web, do a search on google for vertical aligning a div.

  6. #6
    Join Date
    May 2009
    Location
    Hampshire, UK
    Posts
    277
    okay then forget what I have just posted. Hope all goes well

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles