Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

align text inside drop down to middle

Here is my html

  <select id="ddlCountry" placeholder="optional" class="select" title="Select Country">
 <option value="0">country</option>
</select>

Here is the css

    .select
{
    width: 224px;
    border: none;
    font: normal 14px/16px "HelveticaNeueLTCom45Light" , Georgia,serif;
    display: block;
    float: none;
    height: 32px;
    margin-top: 9px;
    border:1px solid;
    color: #6d6e71;
    padding: 0px 4px 0px 4px;
    background: url(../images/selectbg.png) no-repeat right 9px #fff;
    -webkit-appearance: none;
}

The issue is the text inside the drop down is aligned to top in Mozilla but looks perfect and aligned to middle in other browsers. Any way to align text to middle of drop down in all browsers.

Here is the jsfiddle

like image 626
iJade Avatar asked Aug 05 '26 16:08

iJade


1 Answers

Use top and bottom padding and remove height to align the text in the middle, like

.select{ padding: 4px; }

Your updated CSS would be

.select{
    width: 224px;
    border: none;
    font: normal 14px/16px "HelveticaNeueLTCom45Light" , Georgia,serif;
    display: block;
    float: none;
    margin-top: 9px;
    border:1px solid;
    color: #6d6e71;
    padding: 4px;
    background: url(../images/selectbg.png) no-repeat right 9px #fff;
    -webkit-appearance: none;
}
like image 120
Alex Avatar answered Aug 07 '26 06:08

Alex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!