Results 1 to 5 of 5

Thread: Staying in the center

  1. #1

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303

    Question Staying in the center

    I'm trying to position 3 images that stay in the middle of the screen regardless of the resolution and without using a table to do it. I think it can be done via a style sheet, but how?

    <div class="x">
    <img alt="front_1.gif (3K)" src="Images/front_1.gif" height="54" width="700"><br>
    <img alt="front_2.gif (10K)" src="Images/front_2.gif" height="63" width="700"><br>
    <img alt="front_3.gif (13K)" src="Images/front_3.gif" height="61" width="700"><br>
    </div>
    These would be the images
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Yes, CSS

    You can set "margin:auto;" on the img tags for the "correct" way to do it, which would center it in the middle of the div. For IE, you'll need to add "text-align:center;" to the div tag.

    Do you want vertical alignment as well? You could use absolute positioning the put the images wherever you want, and use some javascript to compute it on the fly, but in my experience, while you can get the screen resolution with "screen.width", etc, its trickier to get the actual size of the browser's "canvas".
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  3. #3

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303
    Thanks for that, do you have an example of the vertical alignment ,I've been trying for ages to get that to work, but having no luck.
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  4. #4
    Hyperactive Member GingerNut's Avatar
    Join Date
    May 2002
    Location
    Are those my feet?
    Posts
    372
    It's easier using tables to center it both horizontally and vertically.
    How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?

    Global Freelancers | Web Traffic Analyser

  5. #5
    Hyperactive Member GingerNut's Avatar
    Join Date
    May 2002
    Location
    Are those my feet?
    Posts
    372
    You could use this:

    <table border=0 cellpadding=0 cellspacing=0 height="100%" width="100%">
    <tbody>
    <tr align=middle>
    <td>
    <table border="0" cellpadding="0" cellspacing="0" width="700">
    <tr>
    <td>
    <img alt="front_1.gif (3K)" src="Images/front_1.gif" height="54" width="700"><br>
    <img alt="front_2.gif (10K)" src="Images/front_2.gif" height="63" width="700"><br>
    <img alt="front_3.gif (13K)" src="Images/front_3.gif" height="61" width="700"><br>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </tbody>
    </table>
    How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?

    Global Freelancers | Web Traffic Analyser

Posting Permissions

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



Click Here to Expand Forum to Full Width