Setting the height of a SELECT in IE

前端 未结 14 1924
忘掉有多难
忘掉有多难 2020-12-03 04:24

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 b

14条回答
  •  一生所求
    2020-12-03 05:21

    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: 6px 4px;
        -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?

提交回复
热议问题