开发者

How to make my web page look the same on IE and Google Chrome?

开发者 https://www.devze.com 2023-03-20 20:36 出处:网络
I designed a web page using HTML, and when I try to open my website using Google Chrome it works fine and everything is good.

I designed a web page using HTML, and when I try to open my website using Google Chrome it works fine and everything is good.

but when I try to open the same web page on internet explorer its corrupted, the styles aren't 开发者_StackOverflow社区the way they are ?

can anyone tell me a way to make my website appear on internet explorer the same way it does on Google chrome !!!

is there a script to write or some tag to add to my header ?

Best Regards.


Entire books could be (and probably have been) written on this subject. Your styles are not "corrupted", they are just being interpreted differently by IE than Chrome (and most other browsers).

In terms of how to fix it, adding an IE-specific stylesheet is a common solution, and probably one of the most practical. You can use conditional comments to include it, like:

<!-- Everyone gets the default stylesheet -->
<link rel="stylesheet" type="text/css" href="/css/styles.css" />

<!-- Anyone using IE7 and above gets the IE styles too -->
<!--[if gte IE 7]>
    <link rel="stylesheet" type="text/css" href="/css/ie-overrides.css" />
<![endif]-->

Then it's up to you to implement the styles that you put in ie-overrides.css so that they make your site look the same in IE as in other browsers. Depending upon just how broken your IE layout is, this can be a relatively quick job, or it may drag on and on for what feels like an eternity. And then you'll understand why so many web developers dislike IE.


I never start a site without the http://html5boilerplate.com/ project.

It resets a ton of idiosyncratic browser behaviour and allows you to target styles just for IE or its versions without needing specific style sheets.


Try to use CSS Reset Sheets http://meyerweb.com/eric/tools/css/reset/


First off check your page with http://validator.w3.org/ and the css-validator at the bottom to make sure your code is standards compliant, also read this page about what can trigger ie into quirks mode http://www.quirksmode.org/css/quirksmode.html . Another thing is to look into ie7-js(and ie8-js, it also supports previous versions) which is "A JavaScript library to make MSIE behave like a standards-compliant browser."

0

精彩评论

暂无评论...
验证码 换一张
取 消