IE8 text-align: center Left-sided solution

Source: Internet
Author: User
Keywords Webpage making CSS tutorial
Tags application browsers css tutorial different display displays example problems

The application of text-align: center shows different effects in different browsers, this article shows different displays in IE7, IE8 and IE9, and solves the problem of left-deviation displayed in IE8.

In IE7 and some browsers interpreted as elements and text within the element are centered.

In IE8 and IE9, some browsers interpret that the text within the element is centered.

E.g:
<div style = "border: 1px solid red; height: 150px; width: 150px; text-align: center;">
<div style = "border: 1px solid green; height: 100px; width: 100px;"> </ div>
Hello there
</ div>

Can be found in IE7, the elements use the text-align: center; After the div and the text are centered,

In IE8, the text within the element is centered, but the div element is not centered.

There are two solutions to this type of imbalance.

1 is ie7 tend to ie8, that is, ie7 also showed the effect of IE8, the element left home. The method is to add float: left on the element inside it

2 is so ie8 trend ie7 that is, ie8 also shows the effect of ie7, the element is centered. The method is to add margin: 0 auto inside the element; it's fine.

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.