打造自己的reset.css读书笔记

   目前流行的是:目前比较流行的有Eric Meyer的重置样式和YUI的重置样式。

  为什么我们要用重置样式reset.css呢?那是因为在工作中碰到显示要浏览器兼容的问题,而我们希望尽可能的少些浏览器兼容的代码,可是偏偏不同的浏览器有自己的默认样式,比如li的margin-top在a浏览器里是3px,而在b浏览器里又可能是2px,这样做出来的效果在a浏览器一个样,在b浏览器里又一个样,怎么尽可能地避免这种问题呢,就是自己用"重置样式",尽可能的让要用到的标签的样式由自己来统一,因为开发者为网站设定的样式一般情况下都是是优先于浏览器的默认样式的,所以,如果我们自己为li的margin-top设为2px,那么,现在在a浏览,li的margin-top是2px,在b浏览器里margin-top还是2px,那么不就能把一些浏览器兼容的问题解决了么?当然,浏览器的兼容问题不是能这么轻松就能解决的,但至少,已经能令我们前端开发者少操一些心了...

我是用YUI的重置样式:

  

/*
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 3.3.0
build: 3167
*/
/*
	TODO will need to remove settings on HTML since we can't namespace it.
	TODO with the prefix, should I group by selector or property for weight savings?
*/
html{
	color:#000;
	background:#FFF;
}
/*
	TODO remove settings on BODY since we can't namespace it.
*/
/*
	TODO test putting a class on HEAD.
		- Fails on FF. 
*/
body,
div,
dl,
dt,
dd,
ul,
ol,
li,
h1,
h2,
h3,
h4,
h5,
h6,
pre,
code,
form,
fieldset,
legend,
input,
textarea,
p,
blockquote,
th,
td {
	margin:0;
	padding:0;
}
table {
	border-collapse:collapse;
	border-spacing:0;
}
fieldset,
img {
	border:0;
}
/*
	TODO think about hanlding inheritence differently, maybe letting IE6 fail a bit...
*/
address,
caption,
cite,
code,
dfn,
em,
strong,
th,
var {
	font-style:normal;
	font-weight:normal;
}
/*
	TODO Figure out where this list-style rule is best set. Hedger has a request to investigate.
*/
li {
	list-style:none;
}

caption,
th {
	text-align:left;
}
h1,
h2,
h3,
h4,
h5,
h6 {
	font-size:100%;
	font-weight:normal;
}
q:before,
q:after {
	content:'';
}
abbr,
acronym {
	border:0;
	font-variant:normal;
}
/* to preserve line-height and selector appearance */
sup {
	vertical-align:text-top;
}
sub {
	vertical-align:text-bottom;
}
input,
textarea,
select {
	font-family:inherit;
	font-size:inherit;
	font-weight:inherit;
}
/*to enable resizing for IE*/
input,
textarea,
select {
	*font-size:100%;
}
/*because legend doesn't inherit in IE */
legend {
	color:#000;
}

 1。基础,不要用    

1 * { margin: 0; padding: 0; }

   

2 。默认色彩:不要在reset中设置背景色和文字颜色。

3 。margging和padding:  推荐YUI的做法 。

 4. 边框:推荐用 YUI的。

5.像Eric的,外边框(outline)

1 * remember to define focus styles! */
2 :focus {
3 outline: 0;
4  }
..
原文地址:https://www.cnblogs.com/lanyueer/p/2064280.html