Skip to content Skip to sidebar Skip to footer

Setting The Height Of A Select In Ie

IE seems to ignore the height set in CSS when rendering a HTML SELECT. Are there any work around's for this or do we have to just accept IE will not look as good as other browsers?

Solution 1:

There is no work-around for this aside from ditching the select element.

Solution 2:

It is correct that there is no work-around for this aside from ditching the select element, but if you only need to show more items in your select list you can simply use the size attribute:

<selectmultiple="multiple"size="15"><option>1</option><option>2</option><option>3</option><option>4</option></select>

Doing this you'll have additional empty lines if your collection of items lenght is smaller than size value.

Solution 3:

you can use a combination of font-size and line-height to force it to go larger, but obviously only in the situations where you need the font larger too

edit:

Example -> http://www.bse.co.nzEDIT: (this link is no longer relevant)

the select next to the big search box has the following css rules:

#navigation#search.locationDrop {
    font-size:2em;
    line-height:27px;
    display:block;
    float:left;
    height:27px;
    width:200px;
}

Solution 4:

Yes, you can.

I was able to set the height of my SELECT to exactly what I wanted in IE8 and 9. The trick is to set the box-sizing property to content-box. Doing so will set the content area of the SELECT to the height, but keep in mind that margin, border and padding values will not be calculated in the width/height of the SELECT, so adjust those values accordingly.

select {
    display: block;
    padding: 6px4px;
    -moz-box-sizing: content-box;
    -webkit-box-sizing:content-box;
    box-sizing:content-box;
    height: 15px;
}

Here is a working jsFiddle. Would you mind confirming and marking the appropriate answer?

Solution 5:

Use a UI library, like jquery or yui, that provides an alternative to the native SELECT element, typically as part of the implementation of a combo box.

Post a Comment for "Setting The Height Of A Select In Ie"