Auto resize width of select box to fit active option?

Discussion in 'HTML & Website Design' started by Mr.Submit, May 12, 2010.

  1. #1
    Hi,
    I am trying to blend a select box in a text area by auto-resizing to fit the width of actually active option text.
    e.g:
    <select class="style01">
    <option>short item</option>
    <option>very loooooooooooooooooooooooooooooooooong item</option>
    </select>
    I don't want to see the blank area when "short item" is active.
    Is there any way to do it by css or javascript?
    Thanks in advance.

    PS: I am steeling an image from another site to make my question more clear:
    [​IMG]
     
    Last edited: May 12, 2010
    Mr.Submit, May 12, 2010 IP
  2. Piggy

    Piggy Active Member

    Messages:
    574
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    70
    #2
    I wouldn't use a Select Box of that nature. I'm not a php guy, but I know that it'd be much easier to write a small php code, or even a javascript code, that would provide you what you're looking for. Research "PHP selection box" or "javascript selection box", or something along the nature of those.
     
    Piggy, May 12, 2010 IP
    Mr.Submit likes this.