In IE9, the vertical center of CSS line-height text is invalid.

Source: Internet
Author: User

In IE9, the DIV + CSS webpage is often written. Sometimes the text cannot be vertically centered and line-height is invalid. Even if you can set the compatibility mode of IE browser, however, for visitors, it is impossible for everyone to set the compatible mode for browsing. This is only a solution to hide your ears and ears. What should we do? I had to search for it. Baidu only found the reason. The original reason why IE9 does not support line-height is that Chinese ie9 does not support English fonts, and I just used English fonts.

On IE9, you can see that you can use line-height to set vertical center text to not vertical center. This is related to the font setting.

The code is as follows: Copy code

Font-family: Arial, Helvetica, sans-serif;

Solution to line-height failure in ie9:

You only need to set the font and add a to solve the problem, such as CSS code.

The code is as follows: Copy code

Font-family: Arial, "", Helvetica, sans-serif;

Note when setting the font. You also need to set the default font that comes with the system, such as,.

In Chinese IE9, the English font is not recognized, so IE9 cannot find the set Chinese font, which causes the font to become vertical and vertical.


If only Chinese fonts are used in CSS, we can convert the Chinese font name to Unicode encoding.

Unicode conversion example:

: 5B8B4F53
Simhei: 9ED14F53
5: 5FAE8F6F96C59ED1

You can remember to save the above URL for reference when converting Chinese to Unicode during CSS development.

As follows:

The code is as follows: Copy code

Div {font-family: "";}

After transfer: www.111cn.net

Div {font-family: "5B8B4F53 ";}

Note when setting the font. You also need to set the default font that comes with the system, such as,.

In Chinese IE9, the English font is not recognized, so IE9 cannot find the set Chinese font, which causes the font to become vertical and vertical.


Example:Convert Chinese characters in Chinese fonts to Unicode encoding

After converting a Chinese character to a Unicode character, the font effect is the same, not affected, and compatible with various browsers.

After converting Chinese characters to Unicode characters, the corresponding font is successfully set and compatible with the vertical center line-height style supported by the IE 9 browser.

For example:

The code is as follows: Copy code

. Div {font-family: ""}

After conversion to Unicode encoding

. Div {font-family: "5FAE8F6F96C59ED1 "}

  

Example B:Use Chinese characters in Chinese fonts as English names

In the CSS + DIV layout, set the Chinese font to the English font corresponding to the Chinese font. After the conversion, set the Chinese font effect unchanged and be compatible with various browsers.

For example:

The code is as follows: Copy code

. Div {font-family: ""}

After converting to English name

. Div {font-family: "Microsoft YaHei "}

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.