Text Padding in Select Boxes

前端 未结 6 707
孤街浪徒
孤街浪徒 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 07:02

    The padding you are seeing is coming from the browser specific stylesheet. In chrome the attribute that is responsible for styling these dropdowns is -webkit-appearance, in firefox it is -moz-appearance

    You can standardize the look of your select menus by doing the following:

    select {
        -webkit-appearance: none;
        -moz-appearance : none;
        border:1px solid #ccc;
        border-radius:3px;
        padding:5px 3px;
    }
    

    Note: this will not produce good looking results, only give you standard padding/spacing in your select box. To achieve good looking, customizable select boxes that you can fully control the padding/size etc there are tons of tutorials out there. Here is one I found after a quick google search:

    http://www.htmllion.com/default-select-dropdown-style-just-css.html

提交回复
热议问题