Center Align Text with Select Option

人走茶凉 提交于 2019-12-08 05:34:28

问题


How to vertically Align a text with a Select Option.

Link: http://mink7.com/projects/test/dashboard.html


回答1:


Use labels as in this example fiddle. Markup:

<form action="">
    <label for="startDate">Start Date:</label>
    <select id="startDate">
        <option value="Mar 04">Mar 04</option>
    </select>
    <label for="endDate">End Date:</label>
    <select id="endDate">
        <option value="Aug 04">Aug 04</option>
    </select>
</form>

When this does not work, then there are some inherited styles interfering and try to set vertical-align: middle as shown in this demo.




回答2:


In IE and Chrome the select tag text is aligned center automatically, not in firefox. To only target firefox with a padding, without compromising IE and Chrome: Use a browser specific hack for FF and give it a padding-top:

@-moz-document url-prefix() {
        .select select{
                 padding-top: 8px;
                 }
        }


来源:https://stackoverflow.com/questions/10028788/center-align-text-with-select-option

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