Solve the problem that the DIV + CSS website under IE8.0 is not centered

Source: Internet
Author: User

This article focuses on solving the problem that DIV + CSS Websites under IE8.0 are not centered. I believe this article will surely help you gain some benefits.

Solution for DIV + CSS website not centered under IE8.0

Generally, DIV + CSS writes have basically gone through IE6.0, IE7.0 and Firefox browser tests, because many users have not experienced misplacement, and IE8 is used to open the website and it is found that the misplacement is very serious, including the home page, list page, article page, and so on, are seriously misplaced.

I did not dare to use IE8.0 to open the website in the next two days. I hope that there will not be too many people using IE8, so there will not be too many people who will find the website dislocation problem. Later, I thought, it is not a way to escape. After all, IE8 will only use more people, and it is impossible to use fewer people. I started to study the causes and solutions of website dislocation under IE8.

Because the website was normal in IE7 and then misplaced in IE6, it was implemented by changing the code. Then I thought that the website was misplaced in IE8, will it be necessary to change the code to avoid website dislocation. This is an annoyance. After all, it is a challenge for too many new webmasters. In fact, the Internet Explorer 8 itself has a good function to improve the website dislocation problem.

I. Client Solution

In fact, the solution is very simple. Open your website in the IE 8 browser. Don't be alarmed if you find any misplacement problem. On the menu bar, open the "Tools" option, find "Compatibility View" in the drop-down menu, and check it. Then, check whether the website is no longer misplaced.

2. Website Solution

IE8 is no longer useful to margin: 0 auto; this CSS does not seem to be useful, and the page cannot be centered. I will come back in the afternoon to see how to center it. The front-end of the Pacific also said that their company ignored the existence of IE8, test or previous version.
The reason is found. I wrote the margin: 0 auto; in the body tag. IE7 and lower can be centered, and IE8 won't work. The solution is, write this code in the div framework.

Baidu search materials:

Program code

 
 
  1. <Styletypestyletype = "text/css">
  2. Body {text-align: center; width: 100% ;}
  3. # Wrap {
  4. Text-align: left;
  5. Width: 560px;
  6. Margin: 0 auto;
  7. Border: 1 pxsolid #333;
  8. Background-color: # ccc;
  9. }
  10. </Style>
  11. <Dividdivid = "wrap"> effective methods in all browsers: <pre>
  12. Effective methods in all browsers:
  13. Effective methods in all browsers: effective methods in all browsers:
  14. </Pre>
  15. </Div>

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.