SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict palgrave's Avatar
    Join Date
    Jan 2006
    Posts
    357
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ie6 max width set in percent

    Hi all,

    I have googled and looked in forums, as well as searching the sitepoint forums, and can't find a suitable answer.

    What is the best way to set the maximum width of a div as a percentage of the parent div in ie6?

    I am using a 3 column liquid layout based on the example in the Sitepoint book HTML Utopia: Designing Without Tables.

    For those of you familiar with it, I want 2 divs inside the content.inner, one 30% of the container.

  2. #2
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IE 6 doesn't understand min/max-width, so you're going to have to resort to an expression or filter for this. This should be in the CSS FAQ though.

    http://www.svendtofte.com/code/max_width_in_ie/

  3. #3
    SitePoint Addict palgrave's Avatar
    Join Date
    Jan 2006
    Posts
    357
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't mind using an expression filter, I just can't find one that deals in percent of the containing div.

    I already read that page you linked to Dan. If I'm reading it right, it sets the width of an element depending on the size of the viewport. Also, it depends a lot on the font-size being used.

    I want a box to be 30% of the width of the box it's in.

  4. #4
    Kiwi Fr00t jylyn's Avatar
    Join Date
    Apr 2005
    Location
    New Zealand
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this...

    HTML Code:
    <div id='container'>
      <div style="width: expression(this.width > document.getElementById('container').offsetWidth /3 ? (document.getElementById('container').offsetWidth /3 +1) + 'px' : 'auto');"></div>
    </div>
    I haven't tested it, and of course dividing the width by 3 is not equal to 30&#37;, but you could be more specific with that if necessary.

    Hope that helps!

  5. #5
    SitePoint Addict palgrave's Avatar
    Join Date
    Jan 2006
    Posts
    357
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll give that a try. Thanks very much.


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
  •