Limiting width of <select> box

Discussion in 'HTML' started by Manny Klystron, Dec 20, 2006.

  1. How do I peg the width of the box generated by a <select> tag, clipping
    <options> that're too long for it? It's turning out to be difficult to
    google for.


    This is IE6, IE7, Safari. IE7 is ignoring the "clip: rect{}" style.
    Options are generated in code, so I could do a measure there and clip
    by hand, but I wouldn't think I'd need to.


    Thanks!
    Manny Klystron, Dec 20, 2006
    #1
    1. Advertising

  2. Manny Klystron

    Toby Inkster Guest

    Manny Klystron wrote:

    > How do I peg the width of the box generated by a <select> tag, clipping
    > <options> that're too long for it?


    Errr... <SELECT style="width:120px;">

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Dec 21, 2006
    #2
    1. Advertising

  3. Scripsit Toby Inkster:

    >> How do I peg the width of the box generated by a <select> tag,
    >> clipping <options> that're too long for it?

    >
    > Errr... <SELECT style="width:120px;">


    That might, of course, actually "work" and possibly truncate the options to,
    say, two or three characters. Depending on the font size, which _can_ be
    enforced by the user.

    Instead of creating such problems, the OP should analyze and perhaps
    describe us the original problem and the reasons he though that limiting the
    width of <select> would solve it. If it's the usual "problem", namely an
    attempt to maintain a rigid pixel-dimensioned layout and make a form very
    small, then the real solution is to stop creating such problems.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, Dec 21, 2006
    #3
  4. Thanks folks, I stupidly assumed <SELECT width="120px"> would do the
    same, but IE7 does honor it in a style. Unfortunately it doesn't honor
    style="text-overflow:ellipsis", so the <option>s just get truncated.

    And yes, this is for a fixed-width widget. I didn't design it, and
    it's for a small captive audience.

    On that note, where's a good place to look for implementing spiffy
    Google-style widget drag and drop?

    Jukka K. Korpela wrote:
    > Scripsit Toby Inkster:
    >
    > >> How do I peg the width of the box generated by a <select> tag,
    > >> clipping <options> that're too long for it?

    > >
    > > Errr... <SELECT style="width:120px;">

    >
    > That might, of course, actually "work" and possibly truncate the options to,
    > say, two or three characters. Depending on the font size, which _can_ be
    > enforced by the user.
    >
    > Instead of creating such problems, the OP should analyze and perhaps
    > describe us the original problem and the reasons he though that limiting the
    > width of <select> would solve it. If it's the usual "problem", namely an
    > attempt to maintain a rigid pixel-dimensioned layout and make a form very
    > small, then the real solution is to stop creating such problems.
    >
    > --
    > Jukka K. Korpela ("Yucca")
    > http://www.cs.tut.fi/~jkorpela/
    Manny Klystron, Dec 21, 2006
    #4
  5. Manny Klystron wrote:

    Please don't top post

    > Thanks folks, I stupidly assumed <SELECT width="120px"> would do the
    > same, but IE7 does honor it in a style. Unfortunately it doesn't honor
    > style="text-overflow:ellipsis", so the <option>s just get truncated.


    Never heard of CSS property text-overflow. Googled, ah yes that makes
    sense now it is some MS invention...


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Dec 21, 2006
    #5
  6. Manny Klystron

    Ervin Guest

    Ervin, May 17, 2007
    #6
  7. Manny Klystron

    Mychal Guest

  8. Manny Klystron

    Jovany Guest

  9. Manny Klystron

    Nathaniel Guest

    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AndrewF
    Replies:
    1
    Views:
    766
    Bruce Barker
    Oct 10, 2005
  2. GregG
    Replies:
    5
    Views:
    31,576
    JasonJ
    Jul 11, 2007
  3. Michael Laplante

    Limiting content width - DIV or BODY?

    Michael Laplante, Apr 29, 2006, in forum: HTML
    Replies:
    59
    Views:
    1,600
    Neredbojias
    May 3, 2006
  4. Manny Klystron

    Limiting width of <select> box

    Manny Klystron, Dec 20, 2006, in forum: HTML
    Replies:
    1
    Views:
    425
    Adrienne Boswell
    Dec 23, 2006
  5. palmiere
    Replies:
    1
    Views:
    396
    Erwin Moller
    Feb 9, 2004
Loading...

Share This Page