文章内容

2022/4/2 15:14:09,作 者: 黄兵

reset.css

最近在写前端页面,浏览器的默认行为导致显示出现问题,所以需要重置浏览器的默认样式。

这里给出的重置样式是故意非常通用的。例如:body,没有为元素设置任何默认颜色或背景。我不特别建议您在自己的项目中以未更改的状态使用它。它应该被调整、编辑、扩展或以其他方式调整以匹配您的特定重置基线。为页面、链接等填写您喜欢的颜色。

下面是重置浏览器的默认样式 css 代码:

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

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, 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,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
	display: block;
}
body {
	line-height: 1;
}
ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}

通过上面代码,就可以消除浏览器默认样式,在引用的时候,记得标注协议,具体可以看👇文章来源。


文章来源:CSS Tools: Reset CSS

分享到:

发表评论

评论列表