SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Quake 1 Addict CreedFeed's Avatar
    Join Date
    Feb 2002
    Location
    Milwaukee, WI
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    min-width and IE's expression()

    I am trying to set a minimum width for my page to stop items from collapsing on top of one another (like how SitePoint's top navigation tabs do when you resize the browser small). I know about the "min-width" attribute but that doesn't work in IE. I then found out about the expression() function. So now I have the following code:
    Code:
    #pagebody {
    	min-width: 700px;
    	width: expression(document.body.clientWidth > 700? "auto": "700px" );
    }
    My question is, will using the expression() function there cause any problems on browsers other than IE? I've tried it in Netscape 7, Mozilla, Firebird, and Opera and all seem to ignore it.

    Also, would doing the following be better than having it just in the regular #pagebody id?
    Code:
    * html #pagebody {
    	width: expression(document.body.clientWidth > 700? "auto": "700px" );
    }
    -- Steve Caponetto
    Quake 1 Resurrection :: CreedFeed

  2. #2
    Super Ninja Monkey Travis's Avatar
    Join Date
    Dec 2001
    Location
    Sioux City, Iowa
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe IE treats width the same way the others treat min-width so you could just do this:
    Code:
      * html #pagebody {
     	width: 700px;
     }
    Travis Watkins - Hyperactive Coder
    My Blog: Realist Anew
    Projects: Alacarte - Gnome Menu Editor

  3. #3
    Quake 1 Addict CreedFeed's Avatar
    Join Date
    Feb 2002
    Location
    Milwaukee, WI
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I forgot to add that my page design spans across the whole browser. If I set the width to be 700px then the design won't span the entire width of the browser. I only want to prevent the page from squeezing together and making items collapse on top of one another when the browser is resized smaller than 700 pixels.
    -- Steve Caponetto
    Quake 1 Resurrection :: CreedFeed

  4. #4
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    I've read that expressions should be ignored by other browsers and shouldn't cause any problems. However I think you're wise to use them within the star selector bug as only ie passes that anyway.

    Just check your code thourougly in ie as I've found that expressions can crash the browser if something is not quite correct.

    Paul

  5. #5
    SitePoint Wizard Dangermouse's Avatar
    Join Date
    Oct 2003
    Posts
    1,024
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    "I've found that expressions can crash the browser"
    In true Microsoft fashion

  6. #6
    SitePoint Zealot rae's Avatar
    Join Date
    Apr 2003
    Location
    bedroom :P
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dangermouse
    Off Topic:

    "I've found that expressions can crash the browser"
    In true Microsoft fashion :)
    Yea :) It's like:

    You can download the upgraded software here:
    http://bla...bla...

    New features:
    + Added functionality to crash the browser whenever you want.

    goood thing :)))))))))
    d(o.O)b -- Notice: undefined variable: /me

  7. #7
    Quake 1 Addict CreedFeed's Avatar
    Join Date
    Feb 2002
    Location
    Milwaukee, WI
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually when I originally tested my code, I crashed IE... I had the following:

    Code:
    * html #pagebody {
    	width: expression(document.body.clientWidth < 700? "700px": "auto" );
    }
    This crashed the browser, so I switched it to be > 700 instead and it works fine.
    -- Steve Caponetto
    Quake 1 Resurrection :: CreedFeed

  8. #8
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    [off topic]
    Did you know that expressions work when javascript is disabled. I just found out you can do things like this in ie even (apparently, though I haven't checked) when javscript is turned off:
    Code:
    body{
    background:url(java_script_:alert('hello'))
    }
    Not much use I know but I found it interesting anyway
    [/off topic]


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
  •