SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2001
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Setting table width with css?

    I am planning a new website, the page will be set to margin 0 so in touches the browser window, also the table length was going to be 780px. I want this website to be 800*600 and 1024 * 768 compatiable, I design my sites in a 800*600 resoultion, but I know a large amount of users, use the other size, how using css style sheet would I make it so that both would be possible. In other words what is the style sheet layout code so I can insert it into my design.

    Many thanks for any help

    Michael Prosser

  2. #2
    SitePoint Zealot
    Join Date
    May 2001
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm I don't think u need a stylesheet to do that. 780px in 800x600 is about 95% of the browser window.

    Just set <table width="95%"> and no matter in what resolution, it will still stretch to 95% of the browser width.

    Hope this helps.
    http://winnielim.com- Portfolio site

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    Los Angeles, California
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can u define table width (in either pixels or percentage) using CSS?
    www.iyeinteractive.com - Website Design and Programming
    www.totalnonsense.net - my site, Under Construction

  4. #4
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by wmk86
    can u define table width (in either pixels or percentage) using CSS?
    yes you can. and it is supported in all the various browsers.
    IE, NS, Opera, Mozilla. =)
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  5. #5
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lyon...

    I might be doing it wrong, but this code did not work in Netscape 4.7:

    <style type="text/css">
    .yourtable { width: 50%; }
    </style>

    <table class="yourtable">
    <tr>
    <td>
    some content here some content here some content here some content here some content here some content here some content here some content here
    </td
    </tr>
    </table>
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  6. #6
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm...it works for me. maybe percentage isn't supported?
    I just did a site for a client using pixels and it worked.
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  7. #7
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What version of Netscape did you check in? Just Mozilla? Or did you use 4.7?

    Post the code and let me try it. Maybe my code is wrong.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  8. #8
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I checked it in all the 4 browsers =)

    As always, a separate style sheet for ns and ie. but for width, its the same throughout the 2 style sheets.

    here's a sample.

    table.ct1 {
    width : 600px;
    background : #6372c3;
    }

    <table class="ct1" cellpadding="0" cellspacing="0" border="0" align="center">

    hope it helps you croele.
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  9. #9
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I used that identical code and get a table that stretches the full width of the window in Netscape. It works fine in IE, just not NS 4.7.

    <html>
    <head>
    <style type="text/css">
    table.ct1 { width : 600px; background : #6372c3; }
    </style>

    </head>

    <body>
    <table class="ct1" cellpadding="0" cellspacing="0" border="0" align="center">
    <tr>
    <td>
    some content here some content here some content here some content here some content here some content here some content here some content here some content here some content here some content here some content here some content here </td>
    </tr>
    </table>
    </body>
    </html>
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  10. #10
    SitePoint Zealot honging's Avatar
    Join Date
    Jan 2001
    Location
    Chapel Hill, NC
    Posts
    160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Isn't it kind of self-defeating to use CSS to define a table like that? I can understand going all the way and completely redoing a site using ALL CSS (ALA issue 99), but to still use HTML and then use CSS to define widths seems ... complicated. Just use percentages if you're going to create tables using HTML.

  11. #11
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very puzzling.

    Mine works. If only I could let you see the template. Why don't you ICQ me and I'll show you the entire code?


    honging, when i set widths and background colours in css, if i were to make any changes, i can easily switch to 800 by 600 resolution and above...etc.

    If I could move all to css and maintain compatibility with all the majorbrowsers, i'll defintiely use css all the way.
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein


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
  •