Normalize.css是一种CSS reset的替代方案。经过@necolas@jon_neal花了几百个小时来努力研究不同浏览器的默认样式的差异,这个项目终于变成了现在这样。

我们创造normalize.css有下面这几个目的:

  • 保护有用的浏览器默认样式而不是完全去掉它们
  • 一般化的样式:为大部分HTML元素提供
  • 修复浏览器自身的bug并保证各浏览器的一致性
  • 优化CSS可用性:用一些小技巧
  • 解释代码:用注释和详细的文档来

Normalize.css支持包括手机浏览器在内的超多浏览器,同时对HTML5元素、排版、列表、嵌入的内容、表单和表格都进行了一般化。尽管这个项目基于一般化的原则,但我们还是在合适的地方使用了更实用的默认值。

如何使用 normalize.css

首先,安装或从Github下载Normalize.css,接下来有两种主要途径去使用它。

  • 策略一:将normalize.css作为你自己项目的基础CSS,自定义样式值以满足设计师的需求。
  • 策略二:引入normalize.css源码并在此基础上构建,在必要的时候用你自己写的CSS覆盖默认值。

以下是从GitHub上下载的源码:

/*! normalize.css v6.0.0 | MIT License | github.com/necolas/normalize.css */

/* Document
========================================================================== */ /**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in
* IE on Windows Phone and in iOS.
*/ html {
line-height: 1.15; /* 1 */
-ms-text-size-adjust: 100%; /* 2 */
-webkit-text-size-adjust: 100%; /* 2 */
} /* Sections
========================================================================== */ /**
* Add the correct display in IE 9-.
*/ article,
aside,
footer,
header,
nav,
section {
display: block;
} /**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/ h1 {
font-size: 2em;
margin: 0.67em 0;
} /* Grouping content
========================================================================== */ /**
* Add the correct display in IE 9-.
* 1. Add the correct display in IE.
*/ figcaption,
figure,
main { /* 1 */
display: block;
} /**
* Add the correct margin in IE 8.
*/ figure {
margin: 1em 40px;
} /**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/ hr {
box-sizing: content-box; /* 1 */
height:; /* 1 */
overflow: visible; /* 2 */
} /**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/ pre {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
} /* Text-level semantics
========================================================================== */ /**
* 1. Remove the gray background on active links in IE 10.
* 2. Remove gaps in links underline in iOS 8+ and Safari 8+.
*/ a {
background-color: transparent; /* 1 */
-webkit-text-decoration-skip: objects; /* 2 */
} /**
* 1. Remove the bottom border in Chrome 57- and Firefox 39-.
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/ abbr[title] {
border-bottom: none; /* 1 */
text-decoration: underline; /* 2 */
text-decoration: underline dotted; /* 2 */
} /**
* Prevent the duplicate application of `bolder` by the next rule in Safari 6.
*/ b,
strong {
font-weight: inherit;
} /**
* Add the correct font weight in Chrome, Edge, and Safari.
*/ b,
strong {
font-weight: bolder;
} /**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/ code,
kbd,
samp {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
} /**
* Add the correct font style in Android 4.3-.
*/ dfn {
font-style: italic;
} /**
* Add the correct background and color in IE 9-.
*/ mark {
background-color: #ff0;
color: #000;
} /**
* Add the correct font size in all browsers.
*/ small {
font-size: 80%;
} /**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/ sub,
sup {
font-size: 75%;
line-height:;
position: relative;
vertical-align: baseline;
} sub {
bottom: -0.25em;
} sup {
top: -0.5em;
} /* Embedded content
========================================================================== */ /**
* Add the correct display in IE 9-.
*/ audio,
video {
display: inline-block;
} /**
* Add the correct display in iOS 4-7.
*/ audio:not([controls]) {
display: none;
height:;
} /**
* Remove the border on images inside links in IE 10-.
*/ img {
border-style: none;
} /**
* Hide the overflow in IE.
*/ svg:not(:root) {
overflow: hidden;
} /* Forms
========================================================================== */ /**
* Remove the margin in Firefox and Safari.
*/ button,
input,
optgroup,
select,
textarea {
margin:;
} /**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/ button,
input { /* 1 */
overflow: visible;
} /**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/ button,
select { /* 1 */
text-transform: none;
} /**
* 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
* controls in Android 4.
* 2. Correct the inability to style clickable types in iOS and Safari.
*/ button,
html [type="button"], /* 1 */
[type="reset"],
[type="submit"] {
-webkit-appearance: button; /* 2 */
} /**
* Remove the inner border and padding in Firefox.
*/ button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding:;
} /**
* Restore the focus styles unset by the previous rule.
*/ button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
} /**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/ legend {
box-sizing: border-box; /* 1 */
color: inherit; /* 2 */
display: table; /* 1 */
max-width: 100%; /* 1 */
padding:; /* 3 */
white-space: normal; /* 1 */
} /**
* 1. Add the correct display in IE 9-.
* 2. Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/ progress {
display: inline-block; /* 1 */
vertical-align: baseline; /* 2 */
} /**
* Remove the default vertical scrollbar in IE.
*/ textarea {
overflow: auto;
} /**
* 1. Add the correct box sizing in IE 10-.
* 2. Remove the padding in IE 10-.
*/ [type="checkbox"],
[type="radio"] {
box-sizing: border-box; /* 1 */
padding:; /* 2 */
} /**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/ [type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
} /**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/ [type="search"] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
} /**
* Remove the inner padding and cancel buttons in Chrome and Safari on macOS.
*/ [type="search"]::-webkit-search-cancel-button,
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
} /**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/ ::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
} /* Interactive
========================================================================== */ /*
* Add the correct display in IE 9-.
* 1. Add the correct display in Edge, IE, and Firefox.
*/ details, /* 1 */
menu {
display: block;
} /*
* Add the correct display in all browsers.
*/ summary {
display: list-item;
} /* Scripting
========================================================================== */ /**
* Add the correct display in IE 9-.
*/ canvas {
display: inline-block;
} /**
* Add the correct display in IE.
*/ template {
display: none;
} /* Hidden
========================================================================== */ /**
* Add the correct display in IE 10-.
*/ [hidden] {
display: none;
}

源码下载地址:https://necolas.github.io/normalize.css/latest/normalize.css

浅谈nornalize.css(含源码)的更多相关文章

  1. Android事件分发机制浅谈(三)--源码分析(View篇)

    写事件分发源码分析的时候很纠结,网上的许多博文都是先分析的View,后分析ViewGroup.因为我一开始理解的时候是按我的流程图往下走的,感觉方向很对,单是具体分析的时候总是磕磕绊绊的,老要跳到Vi ...

  2. Android事件分发机制浅谈(二)--源码分析(ViewGroup篇)

    上节我们大致了解了事件分发机制的内容,大概流程,这一节来分析下事件分发的源代码. 我们先来分析ViewGroup中dispatchTouchEvent()中的源码 public boolean dis ...

  3. 浅谈ZooKeeper基本原理与源码分析

    最近一直有小伙伴私信我,问一些关于Zookeeper的知识,下边关于的Zookeeper的知识整理了一下,一起学习一下. 看完本文对于Zookeeper想深入全面了解的读者朋友们,小编这里整理了一份更 ...

  4. 浅谈.Net Core DependencyInjection源码探究

    前言     相信使用过Asp.Net Core开发框架的人对自带的DI框架已经相当熟悉了,很多刚开始接触.Net Core的时候觉得不适应,主要就是因为Core默认集成它的原因.它是Asp.Net ...

  5. ConcurrentHashMap——浅谈实现原理及源码

    本文整理自漫画:什么是ConcurrentHashMap? - 小灰的文章 - 知乎 .已获得作者授权. HashMap 在高并发下会出现链表环,从而导致程序出现死循环.高并发下避免HashMap 出 ...

  6. 浅谈Normalize.css

    浅谈Normalize.css 一.总结 1.Normalize.css:它在默认的HTML元素样式上提供了跨浏览器的高度一致性,花了几百个小时来努力研究不同浏览器的默认样式的差异. 2.优于rese ...

  7. C++ JsonCpp 使用(含源码下载)

    C++ JsonCpp 使用(含源码下载) 前言 JSON是一个轻量级的数据定义格式,比起XML易学易用,而扩展功能不比XML差多少,用之进行数据交换是一个很好的选择JSON的全称为:JavaScri ...

  8. 浅谈对CSS的认识

    自从进公司也有2个多月了,相信和我一批进来的小伙伴们都收获了很多东西,这个是在学校所学不到的,也让成长了很多.作为新人的我,从认为CSS是个很简单的东西,到现在觉得CSS中水很深,感觉学了很多的CSS ...

  9. 微信公众平台开发-OAuth2.0网页授权(含源码)

    微信公众平台开发-OAuth2.0网页授权接口.网页授权接口详解(含源码)作者: 孟祥磊-<微信公众平台开发实例教程> 在微信开发的高级应用中,几乎都会使用到该接口,因为通过该接口,可以获 ...

随机推荐

  1. [20171130]关于rman备份疑问.txt

    [20171130]关于rman备份疑问.txt --//前面测试太乱,重新做一些rman as copy相关测试. 1.环境:SCOTT@book> @ &r/ver1PORT_STR ...

  2. 03-openldap服务端安装配置

    openldap服务端安装配置 阅读目录 基础环境准备 安装openldap服务端 初始化openldap配置 启动OpenLDAP 重新生成配置文件信息 规划OpenLDAP目录树组织架构 使用GU ...

  3. IDisposable

    自己备用 public static class PHDApi : IDisposable { private PHDAccess _phd = null; // Track whether Disp ...

  4. SQL SERVER2008判断文件夹是否存在并创建文件夹

    原文地址:https://www.cnblogs.com/iiwen/p/7650118.html DECLARE @PATH VARCHAR(255) --路径 DECLARE @DATE VARC ...

  5. Ubuntu关闭(重启)网络服务命令

    Ubuntu关闭网络服务命令: service network-manager stop 重启网络服务命令: service network-manager restart

  6. weblogic CVE-2018-2628漏洞利用工具

    weblogic CVE-2018-2628漏洞利用 漏洞环境: Windows2018R2 weblogic10.3.6 漏洞利用过程: 搭建好存在CVE-2018-2628漏洞的weblogic平 ...

  7. Codeforces Round #245 (Div. 2)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/yew1eb/article/details/25609981 A Points and Segmen ...

  8. sed命令替换字符包含斜杠\,引号的处理方法

    在字符替换中,可能会遇见引号,“/”等的替换,这时应该注意,sed的命令原型是: sed -i  "s/oldstring/goalstring/g" file 如果一个路径是da ...

  9. oracle 查询表中数据行(row)上最后的DML时间

    在这介绍Oracle 10G开始提供的一个伪列ORA_ROWSCN,它又分为两种模式一种是基于block这是默认的模式(块级跟踪):还有一种是基于row上,这种模式只能在建里表时指定ROWDEPEND ...

  10. 解决普通用户登录ulimit 报错问题

    [root@master1 ~]# su - fengjian-bash: ulimit: open files: cannot modify limit: Operation not permitt ...