`

几个CSS重置默认样式reset.css代码

css 
阅读更多
  因为各大浏览器存在兼容性问题,同一个CSS属性在不同浏览器下的表现不一定相同,有经验的前端设计者都会自定义一个重置浏览器默认样式的CSS文件,在这个文件中定义一些针对不同浏览器最终表现一致的代码,大家最为熟悉的也许就是*{margin:0 0}了,其实这是最简单照顾兼容性的代码,一般情况下,仅有这个是不够的,笔者收集了几个前端设计网站使用的reset.css代码,为您做参考,你可复制这些代码保存为reset.css文件,在每个页面中引入即可。

CSS重置浏览器样式代码一:
body,ul,li,p,h1,h2,h3,h4,h5,h6,img,br,hr,table,tr,td,dl,dt,dd,form {
	margin: 0;
	padding: 0;
}
body {
	font-family: Arial,"微软雅黑";
	font-size: 12px;
	color: #434343;
}
.clear {
	clear: both;
	font-size: 0px;
}
ul,li {
	list-style: none;
}
img {
	border: none;
}
/*一般链接*/
a {
	text-decoration: none;
	color: #555;
}
a: hover {
	color: #3366ff;
} 


CSS重置浏览器代码二:
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td { background: transparent; border: 0; margin: 0; padding: 0; vertical-align: baseline; font-size: 100%; font: inherit; -webkit-text-size-adjust: none; }
body { line-height: 1; }
table { border-collapse: collapse; border-spacing: 0; }
object, :focus { outline: none; }
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section /* HTML 5 */ { display: block; }
blockquote, q { quotes: none; }
blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; }
a img { border: none; }
input,button,textarea,select,optgroup,option{ font-size: 100%; font: inherit; }
.al { text-align: left; }
.ar { text-align: right; }
.ac { text-align: center; }
.lc { margin: 0 auto; }
.fl, .il .fl { float: left; }
.fr, .il .fr { float: right; }
.fc, .il .fc { float: none; clear: both; }
.rel { position: relative; }
.abs { position: absolute; }
.il { list-style: none; }
.il li { float: left; }


CSS重置浏览器代码三:来自Eric Meyer网站:
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
	margin: 0;
	padding: 0;
	border: 0;
	outline: 0;
	font-weight: inherit;
	font-style: inherit;
	font-size: 100%;
	font-family: inherit;
	vertical-align: baseline;
}
: focus {
	outline: 0;
}
body {
	line-height: 1;
	color: black;
	background: white;
}
ol, ul {
	list-style: none;
}
table {
	border-collapse: separate;
	border-spacing: 0;
}
caption, th, td {
	text-align: left;
	font-weight: normal;
}
blockquote: before, blockquote: after,
q: before, q: after {
	content: "";
}
blockquote, q {
	quotes: "" "";
}


CSS重置浏览器代码四: Normalize.css,这是由 Nicolas Gallagher 和 Jonathan Neal 维护的一个CSS 重置样式库,Bootstrap采用。
/*! 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.
 */

html {
  font-family: sans-serif; /* 1 */
  -ms-text-size-adjust: 100%; /* 2 */
  -webkit-text-size-adjust: 100%; /* 2 */
}

/**
 * Remove default margin.
 */

body {
  margin: 0;
}

/* HTML5 display definitions
   ========================================================================== */

/**
 * Correct `block` display not defined for any HTML5 element in IE 8/9.
 * Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox.
 * Correct `block` display not defined for `main` in IE 11.
 */

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.
 * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
 */

audio,
canvas,
progress,
video {
  display: inline-block; /* 1 */
  vertical-align: baseline; /* 2 */
}

/**
 * Prevent modern browsers from displaying `audio` without controls.
 * Remove excess height in iOS 5 devices.
 */

audio:not([controls]) {
  display: none;
  height: 0;
}

/**
 * Address `[hidden]` styling not present in IE 8/9/10.
 * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
 */

[hidden],
template {
  display: none;
}

/* Links
   ========================================================================== */

/**
 * Remove the gray background color from active links in IE 10.
 */

a {
  background: transparent;
}

/**
 * Improve readability when focused and also mouse hovered in all browsers.
 */

a:active,
a:hover {
  outline: 0;
}

/* Text-level semantics
   ========================================================================== */

/**
 * Address styling not present in IE 8/9/10/11, Safari, and Chrome.
 */

abbr[title] {
  border-bottom: 1px dotted;
}

/**
 * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
 */

b,
strong {
  font-weight: bold;
}

/**
 * Address styling not present in Safari and Chrome.
 */

dfn {
  font-style: italic;
}

/**
 * Address variable `h1` font-size and margin within `section` and `article`
 * contexts in Firefox 4+, Safari, and Chrome.
 */

h1 {
  font-size: 2em;
  margin: 0.67em 0;
}

/**
 * Address styling not present in IE 8/9.
 */

mark {
  background: #ff0;
  color: #000;
}

/**
 * Address inconsistent and variable font size in all browsers.
 */

small {
  font-size: 80%;
}

/**
 * Prevent `sub` and `sup` affecting `line-height` in all browsers.
 */

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.
 */

img {
  border: 0;
}

/**
 * Correct overflow not hidden in IE 9/10/11.
 */

svg:not(:root) {
  overflow: hidden;
}

/* Grouping content
   ========================================================================== */

/**
 * Address margin not present in IE 8/9 and Safari.
 */

figure {
  margin: 1em 40px;
}

/**
 * Address differences between Firefox and other browsers.
 */

hr {
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  height: 0;
}

/**
 * Contain overflow in all browsers.
 */

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.
 *    Known issue: affects color of disabled elements.
 * 2. Correct font properties not being inherited.
 * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
 */

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.
 */

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.
 */

button[disabled],
html input[disabled] {
  cursor: default;
}

/**
 * Remove inner padding and border in Firefox 4+.
 */

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.
 */

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.
 * 2. Remove excess padding in IE 8/9/10.
 */

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`.
 */

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.
 * 2. Address `box-sizing` set to `border-box` in Safari and Chrome
 *    (include `-moz` to future-proof).
 */

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.
 * 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.
 * 2. Remove padding so people aren't caught out if they zero out fieldsets.
 */

legend {
  border: 0; /* 1 */
  padding: 0; /* 2 */
}

/**
 * Remove default vertical scrollbar in IE 8/9/10/11.
 */

textarea {
  overflow: auto;
}

/**
 * Don't inherit the `font-weight` (applied by a rule above).
 * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
 */

optgroup {
  font-weight: bold;
}

/* Tables
   ========================================================================== */

/**
 * Remove most spacing between table cells.
 */

table {
  border-collapse: collapse;
  border-spacing: 0;
}

td,
th {
  padding: 0;
}

分享到:
评论

相关推荐

    1.1css重置样式文件reset.css

    css重置样式文件reset.css

    CSS重置样式表reset.css

    CSS重置样式表 通常情况下,浏览器会为元素设置一些默认样式 默认样式的存在会影响页面的布局,通常情况下编写网页时必须要去除浏览器的默认样式 但是手动去除默认样式过于复杂,实操时,简单项目可以这么做,但是并不...

    web前端重置样式表normalize.css+reset.css

    `reset.css`是Eric Meyer提出的早期重置样式表,它的理念是彻底清除所有元素的默认样式,为开发者提供一个“干净”的起点。`reset.css`通常会将所有元素的边距、填充、字体大小等设置为0,这样开发者可以更自由地...

    CSS中常用的 reset.css文件

    因此,在使用`reset.css`时,最好结合`normalize.css`或现代的CSS重置方法,如`Eric Meyer Reset`或`sanitize.css`,它们不仅重置样式,还会保留一些有助于无障碍浏览和语义化的默认样式。 在实际项目中,可以将`...

    重置样式表reset.css和用于移动端适配的flexible.js

    reset.css 文件的主要目标是消除浏览器之间的样式差异,使得开发者可以更加自由地定义元素的样式,避免受到默认样式的干扰。在重置样式表中,通常会包含对所有常见HTML元素如h1-h6, p, ul, ol, img, table等的样式...

    Reset_CSS css样式重置文件

    CSS Reset即是对浏览器的默认CSS规则进行初始化,保证不同浏览器下CSS的一致性。CSS重设就是由于各种浏览器解释CSS样式的初始值有所不同,导致设计师在没有定义某个CSS属性时,不同的浏览器会按照自己的默认值来为...

    HTML标签默认样式重置文件reset.css

    每一个HTML标签都有它的默认样式,例如标签...通过重新定义标签的样式确保标签在各个浏览器的表现特征一致是我们样式重置的根本原因,在此我总结了一些经常需要重置的标签的默认样式及重置情况。以及写好的重置源文件。

    reset.css & normalize.css 下载

    在实际开发中,许多现代框架和库(如Bootstrap)已经内置了CSS重置或标准化,因此开发者可能不再需要单独引入reset.css或normalize.css。然而,理解这两种方法的工作原理仍然是Web开发中的重要知识。下载并使用...

    css样式重置文件reset.css

    css样式重置文件,去除默认样式。html标签存在一些默认样式,这些样式会影响我们设计网页。css样式重置文件,去除默认样式。html标签存在一些默认样式,这些样式会影响我们设计网页。css样式重置文件,去除默认样式...

    html标签样式重置reset.css文件

    html标签样式重置reset.css文件,取消标签原来特殊样式方便自定义,例如a标签下划线,span标签前面的小圆点,清除浮动解决塌陷的兼容样式

    WEB标准之CSS 打造自己的reset.css

    一个好的reset.css应该是简洁且高效的,不应包含任何设计样式,而是专注于重置所有元素的默认样式。在此基础上,项目的设计和布局可以通过添加额外的CSS样式文件来完成,从而确保网站的样式既符合设计规范,又能保持...

    reset.css文件 CSS代码 下载.zip

    在实际开发中,现代前端框架和库如Bootstrap、 Normalize.css或者CSS重置工具如Eric Meyer's Reset或Reset CSS已经替代了传统的reset.css文件,它们提供了更现代、更全面的样式重置解决方案,减少了手动调整的需求。...

    react项目scss重置浏览器默认样式 normalize.scss

    人力资源管理项目,antd+react前端,重置浏览器默认样式

    重置浏览器默认样式的CSS文件

    CSS重置是通过引入一个专门的CSS文件,该文件中包含了针对各种HTML元素的样式重置规则,例如设置`margin`、`padding`、`border`、`font-size`等属性为0,或者将元素的`display`属性设为`block`,以消除浏览器对这些...

    reset.css 目前最好的css重置版本!

    css重置是很重要的东西. reset.css 目前最好的css重置版本!

    reset.css重置样式文件

    重置样式文件、用于商城页面的外部链接css样式,下载拿来即用,不好用你可以来~我,欢迎前来下载,多多支持,给个小星星给个小赞吧

    尚品汇reset.css

    尚品汇重置样式表,去除一些标签自带样式

    reset.css文件.zip

    这些默认样式可能导致跨浏览器的页面显示不统一,为了解决这个问题,开发者会使用reset.css或normalize.css这样的文件来重置所有元素的样式。 reset.css通常包含一系列CSS规则,如将所有元素的边距、填充、字体大小...

    浏览器样式重置列表reset.css

    这个是比较网站的pc样式重置列表!经过过个项目实践说明,非常ok!

    CSS重置样式清除浏览器默认样式

    CSS重置样式,清除浏览器默认样式,并配置适合设计的基础样式(强调文本是否大多是粗体、主文字色,主链接色,主字体等)。

Global site tag (gtag.js) - Google Analytics