Why the line-height attribute in IE6 browser does not work, ie6line-height

Source: Internet
Author: User

Why the line-height attribute in IE6 browser does not work, ie6line-height

Why is the line-height attribute unavailable in IE 6 browsers:
Suggestion: writing code as much as possible can effectively improve learning efficiency and depth.
Not all situations will cause the line-height attribute to expire in the IE 6 browser, but will be encountered only under specific conditions. For example, the following code is normal:

<! DOCTYPE html> 

The above code runs normally in IE browser. Let's look at the following situation:

<! DOCTYPE html> 

The above Code seems to be vertical center in other mainstream browsers (if you observe carefully, you will find that there is no precise center), but in IE6, line-height is permanently invalid. That is to say, if the text is used together with elements such as img, input, textarea, select, and bject, this will happen.
The solution is as follows:
Add the margin attribute and vertical-align attribute to elements such as img, input, textarea, select, and bject. Set the attributes of margin-top and margin-bottom: the line-height value minus the height of the corresponding element and then divided by two. The above code is modified as follows:

<! DOCTYPE html> 

However, the above Code can only be used for vertical center alignment under IE6 (precise vertical center alignment), but it can only look like vertical center in other browsers, except for images, you can achieve precise vertical center alignment in any browser. That is to say, if it is a form label, it is recommended to use padding to precisely align vertically.

The original address is http://www.51texiao.cn/div_cssjiaocheng/2015/0405/145.html

Related Article

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.