Vertically align text in a asp.net dropdown list control

 ̄綄美尐妖づ 提交于 2020-01-06 13:58:00

问题


How do I vertically align a text in a asp.net dropdownlist control? I researched the web and found several proposed solutions with padding etc. but none seem to work. This is my code.

 <asp:DropDownList ID="DropDownList1" runat="server" CssClass="dropdown">
    <asp:ListItem>sds</asp:ListItem>
    <asp:ListItem>ddd</asp:ListItem>
    <asp:ListItem>xxx</asp:ListItem>
    </asp:DropDownList>

CSS:

.dropdown
{
    height: 35px;
    background-color: Blue;
    font-size: 15px;
    padding-top: 10px;
    padding-bottom: 10px;    
}

回答1:


Add line-height equal to the height:

.dropdown {
    height: 35px;
    line-height: 35px;
    ...
}



回答2:


Padding will work .check out the following jsfiddle

<select class="dropdown">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>

.dropdown {

background-color: Blue;
font-size: 15px;
padding-top: 10px;
padding-bottom: 10px;    

}

JSFIDDLE



来源:https://stackoverflow.com/questions/20934559/vertically-align-text-in-a-asp-net-dropdown-list-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!