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
- <Styletypestyletype = "text/css">
- Body {text-align: center; width: 100% ;}
- # Wrap {
- Text-align: left;
- Width: 560px;
- Margin: 0 auto;
- Border: 1 pxsolid #333;
- Background-color: # ccc;
- }
- </Style>
- <Dividdivid = "wrap"> effective methods in all browsers: <pre>
- Effective methods in all browsers:
- Effective methods in all browsers: effective methods in all browsers:
- </Pre>
- </Div>