[Css -- Form] When the font is 12 PX, the Form (radio, checkbox) is aligned with the text,

Source: Internet
Author: User

[Css -- Form] When the font is 12 PX, the Form (radio, checkbox) is aligned with the text,

The 12 PX font alignment is only applicable to radio and checkbox.

CSS:

<pre name="code" class="html">.form {font-size: 12px; line-height: 1.4}.form .txt {width: 180px; height: 25px; padding:3px; border:1px solid #dbdbdb; line-height: 25px; color:#999; vertical-align: middle}.form .txt:hover,.form .txt:focus {border-color:#51b5f7; color:#333}.form .btn {width: 78px; height: 33px; *margin-top: 1px; border:none; background-color: #31a5f7; border-radius: 3px; font-size: 15px; color:#fff; vertical-align: middle; transition:all .3s linear 0s}.form .btn:hover {background-color: #51b5f7}.form .radio {margin-top: -3px; *margin-top: 0; vertical-align: middle}.form .chkbox {margin-top:1px; margin-top: -2px\9;  *margin-top:0px; vertical-align: middle;}
 

HTML:

<Form action = "#" class = "form"> <div> <input type = "radio" value = "0" name = "media" class = "radio"> Network <input type = "radio" value = "1" name = "media" class = "radio"> TV <input type = "radio" value = "2" name = "media "class =" radio "> newspaper </div> <input type =" checkbox "value =" 0 "name =" media "class =" chkbox "> Network <input type = "checkbox" value = "1" name = "media" class = "chkbox"> TV <input type = "checkbox" value = "2" name = "media" class = "chkbox"> newspaper </div> <input type = "text" name = "input" class = "txt"> <input type = "submit" name = "btnSubmit" value = "Submit" class = "btn"> </div> </form>


It has been tested that IE, Firefox, and chrome are basically perfectly aligned. in safari, checkbox relies on a pixel, but it can be viewed as well.

Note: Setting the text line height to 1.4 (without unit) is the most ideal (the text height is the closest to radio and checkbox height). The upper and lower spacing is controlled by the outer element.

The following is a preview of each Browser:


IE9/10 is slightly different from IE11, but it is not visible to the naked eye. In addition, we can see that, the radio width of the other three browsers except IE is 1px larger than that of the checkbox.


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.