Font center of select labels

Source: Internet
Author: User

When I wrote JSP today, I found that a selection column in the <s: Select> Option box is used, and the font is not vertically centered, I found a problem about the vertical center display content of the select tag on the network, and found that many people encountered the same problem. Some people simply called the select tag the most disgusting tag, because almost no CSS style can be applied to it. Let's see how disgusting the SELECT statement is.

  

   <style type="text/css">              select{           height:50px;           width:100px;           font-size:15px;       }   </style>    select>        <option value="volvo">Volvo</option>        <option value="saab">Saab</option>        <option value="opel">Opel</option>        <option value="audi">Audi</option>    </select>

To highlight that the select tag cannot be vertically centered, we intentionally set the select height to 50px, which is much greater than the font. The results are as follows:

Try to add the CSS style: vertical-align: middle; In option, the effect is not the same, as shown below:

<style type="text/css">       select{           height:50px;           width:100px;           font-size:15px;       }       select option{           vertical-align: middle;       }   </style>    <select>        <option value="volvo">Volvo</option>        <option value="saab">Saab</option>        <option value="opel">Opel</option>        <option value="audi">Audi</option>    </select>

In fact, all the tag libraries that use the select label, such as the <s: Select> of struts2, have the same problem. However, if it is in IE (11 here) and chrome (35.0.1916.153 here), the Select tag can be automatically vertically centered.

The display of Select Content in HTML5 has not been improved. If you want to use the selection box and look good, you can use the DIV + input label to simulate the select label function. For details, refer to extjs ComboBox:

 

You can see through firedebug that extjs shows the select effect and does not encounter the select label, so the display effect is very elegant.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.