问题
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