Stop width

Discussion in 'CSS' started by red-x, Aug 20, 2008.

  1. #1
    Hi, I use % for the width of my website so it looks good in all screen sizes. I want to know if there's a way to stop it from getting smaller ones it reaches 800px because that's the smallest screen size used. Thanks in advance :)
     
    red-x, Aug 20, 2008 IP
  2. happyharry

    happyharry Peon

    Messages:
    93
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think only certain browsers suport min-width, so an idea might be to put a div inside the main content part of the site, that is 1px X 800px wide, this way the main container will not get smaller than that div...

    If you need more help, PM me some more details and im sure i can be of some help :D
     
    happyharry, Aug 20, 2008 IP
  3. red-x

    red-x Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Wow that's awesome thank you so much, the min-width works in FF IE 7-8 (I don't know about 6) and Opera! :D again thank you for your help :)
     
    red-x, Aug 20, 2008 IP
  4. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #4
    min-width works in all browsers except lte IE6. Two general solutions (although the one given by happyharry is clever, but instead of making some useless div for that purpose, try giving this width to something that already exists):

    IE expressions in the CSS example:
    
    #container {
      min-width: 780px;
    }
    
    * html #container {
      width: 780px;
      width: expression((document.body.clientWidth>1400) ? "1350px" : ((document.body.clientWidth>800) ? "auto" : "780px"));
    }
    
    Code (markup):
    I'm still learning javascript, which is what this basically is, and so haven't yet figured out how to do the expression without mentioning a max-width. The width statement before the JS is the default if the browser can't understand the script (no js parser or JS disabled or whatever).
    Second drawback is, when validating the CSS, jigsaw barfs-- you need to comment it out before sending to the validator.
    Because it's hidden behind the * html hack, no other browsers see it.

    Second technique:
    requires no scripting at all, but like harry's requires an additional HTML element. Paul O'brien made it, so I'll just link to his page:http://www.pmob.co.uk/temp/min-width-ie.htm

    Both of these examples are only better than harry's in that they allow (and are made for) a max-width. Simply making someone in your page 800px wide or whatever may be the simpler method-- again, though, just try to find someone who can the do job instead of adding non-semantic elements.
     
    Stomme poes, Aug 20, 2008 IP
  5. happyharry

    happyharry Peon

    Messages:
    93
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    That is a pretty good suggestion Stomme poes :) better than a div floating around :p
     
    happyharry, Aug 20, 2008 IP
  6. red-x

    red-x Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thank you guys :D I'm going to try it ones I get IE6 or my website online.
     
    red-x, Aug 20, 2008 IP
  7. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Still, I overthink things and prolly wouldn't have just realised that if someone on the page is 800ox wide, the page couldn't shrink beyond that-- your solution was actually more elegant, harry : )
     
    Stomme poes, Aug 21, 2008 IP