Text Padding in Select Boxes

前端 未结 6 739
孤街浪徒
孤街浪徒 2020-11-30 06:29

I\'ve just encountered an obscure issue with select boxes having additional space around text which doesn\'t seem part of the box model. Here are two pictures o

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 06:52

    Unfortunately, this extra whitespace is added by the browser's rendering engine. Form element rendering is inconsistent across browsers, and in this case is not determined by CSS.

    Take a look at this article from Mozilla explaining some ways to mitigate select box incosistency, then you might read this article from Smashing Magazine about styling form elements (be sure to check out the comments and the problems people have had with selects).

    Edit 2020: I stumbled across this article from Chris Coyer at CSS-Tricks that appears to show some styling that you can apply to select elements that may help some folks out. It appears overriding the browser's default styling allows you a little more freedom than I was aware of when I posted this answer several years go, according to Liliana Brissos on Team Treehouse.

提交回复
热议问题