Last active
January 4, 2017 10:34
-
-
Save hjzheng/48c77191a495b7c7ec37 to your computer and use it in GitHub Desktop.
normalize.css v3.0.1解读
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! normalize.css v3.0.1 | MIT License | git.io/normalize */ | |
/** | |
* 1. Set default font family to sans-serif. | |
* 2. Prevent iOS text size adjust after orientation change, without disabling | |
* user zoom. | |
* 1. 设置默认的字体sans-serif. | |
* 2. 当屏幕方向改变的时候, 阻止ios自动调整文本大小. | |
* https://developer.mozilla.org/en-US/docs/Web/CSS/text-size-adjust | |
*/ | |
html { | |
font-family: sans-serif; /* 1 */ | |
-ms-text-size-adjust: 100%; /* 2 */ | |
-webkit-text-size-adjust: 100%; /* 2 */ | |
} | |
/** | |
* Remove default margin. | |
* 删除默认的margin | |
*/ | |
body { | |
margin: 0; | |
} | |
/* HTML5 display definitions | |
HTML5元素关于display属性的定义 | |
========================================================================== */ | |
/** | |
* Correct `block` display not defined for any HTML5 element in IE 8/9. | |
* 下面未在IE8/9中定义display属性的任意HTML5元素修正为`block` | |
* Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox. | |
* 未在IE10/11和FireFox定义display属性的元素`details`或`summary`,修正为`block` | |
* Correct `block` display not defined for `main` in IE 11. | |
* 未在IE11中定义display属性的`main`元素,修正为`block` | |
*/ | |
article, | |
aside, | |
details, | |
figcaption, | |
figure, | |
footer, | |
header, | |
hgroup, | |
main, | |
nav, | |
section, | |
summary { | |
display: block; | |
} | |
/** | |
* 1. Correct `inline-block` display not defined in IE 8/9. | |
* 1. 下面在IE8/9中未定义display属性,修正为`inline-block` | |
* 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. | |
* 2. 在Chrome, FireFox和Opera,让progress垂直对齐 | |
*/ | |
audio, | |
canvas, | |
progress, | |
video { | |
display: inline-block; /* 1 */ | |
vertical-align: baseline; /* 2 */ | |
} | |
/** | |
* Prevent modern browsers from displaying `audio` without controls. | |
* 阻止现代浏览器显示audio在未定义controls属性的情况下(在chrome35,FireFox30和IE10没有发现这个问题) | |
* http://www.w3schools.com/tags/tag_audio.asp | |
* Remove excess height in iOS 5 devices. | |
* 在IOS 5设备中,去除元素audio中显示多余的高度 | |
*/ | |
audio:not([controls]) { | |
display: none; | |
height: 0; | |
} | |
/** | |
* Address `[hidden]` styling not present in IE 8/9/10. | |
* 用样式去实现在IE 8/9/10中不支持的hidden属性 | |
* http://www.w3schools.com/tags/att_global_hidden.asp | |
* Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. | |
* 在IE 8/9/11, Safari, and Firefox < 22 隐藏template元素 | |
*/ | |
[hidden], | |
template { | |
display: none; | |
} | |
/* Links | |
========================================================================== */ | |
/** | |
* Remove the gray background color from active links in IE 10. | |
* 删除IE10中active link的灰色背景色 | |
*/ | |
a { | |
background: transparent; | |
} | |
/** | |
* Improve readability when focused and also mouse hovered in all browsers. | |
* 清除a标签在hover和active时的outline | |
*/ | |
a:active, | |
a:hover { | |
outline: 0; | |
} | |
/* Text-level semantics | |
========================================================================== */ | |
/** | |
* Address styling not present in IE 8/9/10/11, Safari, and Chrome. | |
* 处理在IE 8/9/10/11, Safari, and Chrome中的title无下划点线的问题,为与FireFox一致 | |
* http://www.w3schools.com/tags/tag_audio.asp | |
*/ | |
abbr[title] { | |
border-bottom: 1px dotted; | |
} | |
/** | |
* Address style set to `bolder` in Firefox 4+, Safari, and Chrome. | |
* 在Firefox 4+, Safari, and Chrome默认字体样式是加粗,修正所有浏览器与它们一致 | |
*/ | |
b, | |
strong { | |
font-weight: bold; | |
} | |
/** | |
* Address styling not present in Safari and Chrome. | |
* 在Safari and Chrome处理dfn标签样式不存在的情况(chrome30下测试是OK的) | |
* http://www.w3schools.com/tags/tag_dfn.asp | |
*/ | |
dfn { | |
font-style: italic; | |
} | |
/** | |
* Address variable `h1` font-size and margin within `section` and `article` | |
* contexts in Firefox 4+, Safari, and Chrome. | |
* 处理h1标签在section和article中的字体大小和margin | |
*/ | |
h1 { | |
font-size: 2em; | |
margin: 0.67em 0; | |
} | |
/** | |
* Address styling not present in IE 8/9. | |
* 在IE8/9中用样式处理mark标签的样式(IE9测试是支持mark标签,样式和其他浏览器也一致) | |
* http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_mark | |
*/ | |
mark { | |
background: #ff0; | |
color: #000; | |
} | |
/** | |
* Address inconsistent and variable font size in all browsers. | |
* 处理small标签的样式,让其字体大小在所有浏览器一致 | |
*/ | |
small { | |
font-size: 80%; | |
} | |
/** | |
* Prevent `sub` and `sup` affecting `line-height` in all browsers. | |
* 阻止`sub` and `sup` 影响行高在所有的浏览器 | |
*/ | |
sub, | |
sup { | |
font-size: 75%; | |
line-height: 0; | |
position: relative; | |
vertical-align: baseline; | |
} | |
sup { | |
top: -0.5em; | |
} | |
sub { | |
bottom: -0.25em; | |
} | |
/* Embedded content | |
========================================================================== */ | |
/** | |
* Remove border when inside `a` element in IE 8/9/10. | |
* 当a标签在img元素的时候,去除它的边框 | |
*/ | |
img { | |
border: 0; | |
} | |
/** | |
* Correct overflow not hidden in IE 9/10/11. | |
* 修在overflow在IE9/10/11中不隐藏 | |
*/ | |
svg:not(:root) { | |
overflow: hidden; | |
} | |
/* Grouping content | |
========================================================================== */ | |
/** | |
* Address margin not present in IE 8/9 and Safari. | |
* 修正figure标签在IE8/9和Safari中没有margin | |
*/ | |
figure { | |
margin: 1em 40px; | |
} | |
/** | |
* Address differences between Firefox and other browsers. | |
* 修正hr标签在FireFox和其他浏览器的不同 | |
*/ | |
hr { | |
-moz-box-sizing: content-box; | |
box-sizing: content-box; | |
height: 0; | |
} | |
/** | |
* Contain overflow in all browsers. | |
* 在所有浏览器中包含overflow | |
*/ | |
pre { | |
overflow: auto; | |
} | |
/** | |
* Address odd `em`-unit font size rendering in all browsers. | |
* 不清楚为什么这样处理 | |
*/ | |
code, | |
kbd, | |
pre, | |
samp { | |
font-family: monospace, monospace; | |
font-size: 1em; | |
} | |
/* Forms | |
========================================================================== */ | |
/** | |
* Known limitation: by default, Chrome and Safari on OS X allow very limited | |
* styling of `select`, unless a `border` property is set. | |
*/ | |
/** | |
* 1. Correct color not being inherited. | |
* 1. 修正color属性不能被继承 | |
* Known issue: affects color of disabled elements. | |
* 2. Correct font properties not being inherited. | |
* 2. 修正字体属性不能被继承 | |
* 3. Address margins set differently in Firefox 4+, Safari, and Chrome. | |
* 3. 处理margin值 | |
*/ | |
button, | |
input, | |
optgroup, | |
select, | |
textarea { | |
color: inherit; /* 1 */ | |
font: inherit; /* 2 */ | |
margin: 0; /* 3 */ | |
} | |
/** | |
* Address `overflow` set to `hidden` in IE 8/9/10/11. | |
* 修正 overflow被设置成hidden在IE 8/9/10/11 | |
* 参见IE的User Agent stylesheet: http://www.iecss.com/ (需翻墙) | |
*/ | |
button { | |
overflow: visible; | |
} | |
/** | |
* Address inconsistent `text-transform` inheritance for `button` and `select`. | |
* All other form control elements do not inherit `text-transform` values. | |
* Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. | |
* Correct `select` style inheritance in Firefox. | |
*/ | |
button, | |
select { | |
text-transform: none; | |
} | |
/** | |
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` | |
* and `video` controls. | |
* 2. Correct inability to style clickable `input` types in iOS. | |
* 3. Improve usability and consistency of cursor style between image-type | |
* `input` and others. | |
*/ | |
button, | |
html input[type="button"], /* 1 */ | |
input[type="reset"], | |
input[type="submit"] { | |
-webkit-appearance: button; /* 2 */ | |
cursor: pointer; /* 3 */ | |
} | |
/** | |
* Re-set default cursor for disabled elements. | |
* 为disabled元素重新设置默认的cursor样式 | |
*/ | |
button[disabled], | |
html input[disabled] { | |
cursor: default; | |
} | |
/** | |
* Remove inner padding and border in Firefox 4+. | |
* 删除内部补白和边框在FireFox 4+,可以使用最新版本FireBug查看FireFox系统样式forms.css | |
* 也可以参考: http://mxr.mozilla.org/mozilla-central/source/layout/style/forms.css | |
*/ | |
button::-moz-focus-inner, | |
input::-moz-focus-inner { | |
border: 0; | |
padding: 0; | |
} | |
/** | |
* Address Firefox 4+ setting `line-height` on `input` using `!important` in | |
* the UA stylesheet. | |
* 什么是User Agent Stylesheet? http://www.zhihu.com/question/20549293 | |
*/ | |
input { | |
line-height: normal; | |
} | |
/** | |
* It's recommended that you don't attempt to style these elements. | |
* Firefox's implementation doesn't respect box-sizing, padding, or width. | |
* | |
* 1. Address box sizing set to `content-box` in IE 8/9/10. | |
* 1. 修正在IE8/9/10下box-sizing被设置成content-box | |
* 2. Remove excess padding in IE 8/9/10. | |
* 2. 删除多余的padding | |
* 参考: http://www.iecss.com/ | |
*/ | |
input[type="checkbox"], | |
input[type="radio"] { | |
box-sizing: border-box; /* 1 */ | |
padding: 0; /* 2 */ | |
} | |
/** | |
* Fix the cursor style for Chrome's increment/decrement buttons. For certain | |
* `font-size` values of the `input`, it causes the cursor style of the | |
* decrement button to change from `default` to `text`. | |
* | |
* http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_input_type_number | |
*/ | |
input[type="number"]::-webkit-inner-spin-button, | |
input[type="number"]::-webkit-outer-spin-button { | |
height: auto; | |
} | |
/** | |
* 1. Address `appearance` set to `searchfield` in Safari and Chrome. | |
* 1. 修正appearance属性设置searchfield值在Safari和Chrome | |
* 2. Address `box-sizing` set to `border-box` in Safari and Chrome | |
* 2. 修正box-sizing设置border-box值在Safari和Chrome | |
* (include `-moz` to future-proof). | |
* 参考 webkit默认的浏览器样式: http://trac.webkit.org/browser/trunk/Source/WebCore/css/html.css | |
*/ | |
input[type="search"] { | |
-webkit-appearance: textfield; /* 1 */ | |
-moz-box-sizing: content-box; | |
-webkit-box-sizing: content-box; /* 2 */ | |
box-sizing: content-box; | |
} | |
/** | |
* Remove inner padding and search cancel button in Safari and Chrome on OS X. | |
* 在OS X的Safari和Chrome上删除search中的padding和cancel按钮 | |
* http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_input_type_search | |
* Safari (but not Chrome) clips the cancel button when the search input has | |
* padding (and `textfield` appearance). | |
*/ | |
input[type="search"]::-webkit-search-cancel-button, | |
input[type="search"]::-webkit-search-decoration { | |
-webkit-appearance: none; | |
} | |
/** | |
* Define consistent border, margin, and padding. | |
* 定义一致的边框,外边距和内补白 | |
*/ | |
fieldset { | |
border: 1px solid #c0c0c0; | |
margin: 0 2px; | |
padding: 0.35em 0.625em 0.75em; | |
} | |
/** | |
* 1. Correct `color` not being inherited in IE 8/9/10/11. | |
* 1. 修正在IE 8/9/10/11 `color`属性不能被继承 | |
* 2. Remove padding so people aren't caught out if they zero out fieldsets. | |
* 2. 删除padding | |
*/ | |
legend { | |
border: 0; /* 1 */ | |
padding: 0; /* 2 */ | |
} | |
/** | |
* Remove default vertical scrollbar in IE 8/9/10/11. | |
* 删除默认在IE 8/9/10/11的垂直滚动条 | |
* 参考IE的User Agent Style: http://www.iecss.com/ (可能需要翻墙) | |
*/ | |
textarea { | |
overflow: auto; | |
} | |
/** | |
* Don't inherit the `font-weight` (applied by a rule above). | |
* 不要继承font-weight | |
* NOTE: the default cannot safely be changed in Chrome and Safari on OS X. | |
* 注意: 默认值在OS X上的Chrome和Safari上不能安全的被修改(没有MAC,无法测试?) | |
* http://www.w3schools.com/tags/tag_optgroup.asp | |
*/ | |
optgroup { | |
font-weight: bold; | |
} | |
/* Tables | |
========================================================================== */ | |
/** | |
* Remove most spacing between table cells. | |
* 去除table cells之间的空隙 | |
*/ | |
table { | |
border-collapse: collapse; | |
border-spacing: 0; | |
} | |
td, | |
th { | |
padding: 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment