Skip to content

Instantly share code, notes, and snippets.

@WesternRanger
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WesternRanger/520adf7cfc7352817513 to your computer and use it in GitHub Desktop.
Save WesternRanger/520adf7cfc7352817513 to your computer and use it in GitHub Desktop.

#浏览器的怪异模式与标准模式 w3c标准中,浏览器都有两种模式:标准模式与怪异模式。但实际上ie6、7、8这三个浏览器比较非主流,他们只有一种模式,怪异模式。只要没有写头声明<!doctype html>,ie6、7、8就表现为怪异模式。除了这仨哥俩,其他的主流浏览器像chrome虽然有两种模式,但是默认状态下只会开启标准模式。不论写与不写头声明<!doctype html>。

####所谓的怪异模式就是表现为:

(1)盒子的宽度始终是width的值,即使加上了padding和border也不会变;

(2)自动居中的margin-auto和margin-auto失效

所以以后写页面的时候,一定不要忘了在开头写上<!doctype html>。能省去好多事。 ####除此之外,我还看到了一个只适用于ie8的怪异模式解决方案,对ie6、7都不起作用。就是在标签里加上: 这句话的意思是:本文的解析模式按照ie最高版本的方式去解析

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment