ie css min-width max-width

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yb

    ie css min-width max-width

    Hello,

    I've been trying to emulate css min-width and max-width in IE.

    I've looked at various methods on the web, but none seemed to truly
    emulate min-width / max-width, or at least not very elegantly.

    There are two problems I've noticed:
    1) padding / margin around containing element throw off calculations in
    IE, even in strict mode. But there should be work arounds using an
    extra containing element, so this isn't too bad I guess.

    2) Using min-width / max-width with anything other than pixel based
    values is problematic, unless there is some way to convert the units in
    to pixels.

    The code below finds the min-width and max-width in IE as they are in
    the styleSheet using propriatery microsoft "currentSty le" property.
    This does not give the value set with "style" property which is for
    inline styles only, it is the true stylesheet value.

    var e = document.getEle mentById( id );
    var minWidth = e.currentStyle["min-width"];
    var maxWidth = e.currentStyle["max-width"];

    The pixel length of the item e, (the container we want to limit size
    of) is:

    var width = e.clientWidth;

    With these values, we could then compare and limit the size of the
    element in the script. It would be really nice if 'minWidth' and
    'maxWidth' values could be converted into pixels. For example, if they
    were specified in EM units. This is obviously calculated internally in
    IE, is there some way to expose it in the script? Also, I only have
    IE6 to test with, I'm assuming IE5 has the same methods.

  • Spartanicus

    #2
    Re: ie css min-width max-width

    "yb" <bajwa_yasir@ya hoo.ca> wrote:
    [color=blue]
    >I've been trying to emulate css min-width and max-width in IE.
    >
    >I've looked at various methods on the web, but none seemed to truly
    >emulate min-width / max-width, or at least not very elegantly.[/color]

    Are you aware of http://dean.edwards.name/IE7/ ?

    --
    Spartanicus

    Comment

    Working...