简体   繁体   中英

select has Extra top padding from div

I want a dropdown with custom arrow.
I have made a div wrapper with arrow image background around my select.

The problem is that the select has 3-4 pixels top padding from the div. And I can't find the reason.

<style>

    .styleSelect select {
        font-weight:bold;
        -moz-appearance:none;
        -webkit-appearance: none;
        border:none;
        width: 140px;
    }

    .styleSelect select::-ms-expand {
        display: none;
    }

    .styleSelect {
        width: 120px;
        overflow: hidden;
        background: url("/Images/dropdown_arrow.gif") no-repeat right #fff;
        border: 1px solid #000;
        float: right;
        margin-left: 3px;
        border-radius: 8px;
    }

</style>

Here is my html:

<form>
    <div class="styleSelect">     
        <select></select>
    </div>
</form>

You can try this: For this example I use a navbar height of 50px but for the 50 you can use your own navbar or parent object height.

.styleSelect select{
  line-height:50px;
  height:50px;
  /*and ofcourse your other code*/
}

This should center the object vertical. You can also try vertical-align:middle;

嘿,我还发现,如果我向div添加font-size: 0 px ,那也可以

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM