推荐几款主流的Css Reset

news2024/9/25 3:25:49

CSS Reset

CSS Reset(CSS重置)是一种技术,用于消除不同浏览器之间默认样式的差异,以确保网页在各个浏览器中的显示一致性。由于不同浏览器对元素的默认样式有所不同,使用CSS Reset可以将这些默认样式归零或统一,从而为开发者提供一个干净的起点来构建自定义样式。

CSS Reset通常包含一系列CSS规则,用于将HTML元素的属性值重置为一致的初始状态。这些规则可能会将边距、内边距、字体大小、行高等属性设置为相同的值,以消除浏览器之间的差异。

常见的CSS Reset方法包括使用Normalize.css和Eric Meyer’s Reset CSS。Normalize.css是一个广泛使用的CSS Reset库,它通过保留有用的默认样式,并纠正浏览器之间的差异,提供了一致的跨浏览器体验。Eric Meyer’s Reset CSS则是经典的CSS Reset方法之一,它将大部分HTML元素的样式重置为零,并提供了一个基本的布局起点。

在使用CSS Reset时,需要注意以下几点:

  1. 了解选择的CSS Reset方法的具体实现和影响。
  2. 将CSS Reset文件在其他样式文件之前引入,以确保样式重置生效。
  3. 注意可能会影响到已有样式的问题,需要在项目中进行适当的测试和调整。

CSS Reset是一种消除浏览器默认样式差异的技术,它可以为开发者提供一个一致的起点来构建网页样式,并改善跨浏览器的兼容性。

更多精彩内容,请微信搜索“前端爱好者戳我 查看

常用的 Css Reset

Eric Meyer’s “Reset CSS”(重置的很极端)

官方网址:https://meyerweb.com/eric/tools/css/reset/

/* 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;
}

HTML5 Doctor CSS Reset

官方网址:http://html5doctor.com/html-5-reset-stylesheet/


/** 
* html5doctor.com Reset Stylesheet v1.6.1 (http://html5doctor.com/html-5-reset-stylesheet/) 
* Richard Clark (http://richclarkdesign.com) 
* http://cssreset.com 
*/

html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,abbr,address,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,var,b,i,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video {
	margin:;
	padding:;
	border:;
	outline:;
	font-size:100%;
	vertical-align:baseline;
	background:transparent;
}
body {
	line-height:;
}
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section {
	display:block;
}
nav ul {
	list-style:none;
}
blockquote,q {
	quotes:none;
}
blockquote:before,blockquote:after,q:before,q:after {
	content:'';
	content:none;
}
a {
	margin:;
	padding:;
	font-size:100%;
	vertical-align:baseline;
	background:transparent;
}
/* change colours to suit your needs */ins {
	background-color:#ff9;
	color:#000;
	text-decoration:none;
}
/* change colours to suit your needs */mark {
	background-color:#ff9;
	color:#000;
	font-style:italic;
	font-weight:bold;
}
del {
	text-decoration:line-through;
}
abbr[title],dfn[title] {
	border-bottom:1px dotted;
	cursor:help;
}
table {
	border-collapse:collapse;
	border-spacing:;
}
/* change border colour to suit your needs */hr {
	display:block;
	height:1px;
	border:;
	border-top:1px solid #cccccc;
	margin:1em 0;
	padding:;
}
input,select {
	vertical-align:middle;
}

Yahoo! (YUI 3) Reset CSS(推荐)

官方网址:http://developer.yahoo.com/yui/3/cssreset/

/** * YUI 3.5.0 - reset.css (http://developer.yahoo.com/yui/3/cssreset/) 
* http://cssreset.com 
* Copyright 2012 Yahoo! Inc. All rights reserved. 
* http://yuilibrary.com/license/ 
*//*    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:;
	padding:;
}
table {
	border-collapse:collapse;
	border-spacing:;
}
fieldset,img {
	border:;
}
/*    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;
}
ol,ul {
	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:;
	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;
}
/* YUI CSS Detection Stamp */#yui3-css-stamp.cssreset {
	display:none;
}

使用通用选择器“*”

* {
    margin: 0;
    padding: 0;
}

Normalize.css(推荐,因为重置较为标准化,不是很极端)

官方网址:http://necolas.github.io/normalize.css/

  • normalize.css:保护了有价值的默认值
  • normalize.css:修复了浏览器的bug
  • normalize.css:是模块化的
  • normalize.css:拥有详细的文档
/*! normalize.css v8.0.1 | 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 iOS.
 */
html {
  line-height: 1.15; /* 1 */
  -webkit-text-size-adjust: 100%; /* 2 */
}
 
/* Sections
   ========================================================================== */
 
/**
 * Remove the margin in all browsers.
 */
body {
  margin: 0;
}
 
/**
 * Render the `main` element consistently in IE.
 */
main {
  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
   ========================================================================== */
 
/**
 * 1. Add the correct box sizing in Firefox.
 * 2. Show the overflow in Edge and IE.
 */
hr {
  box-sizing: content-box; /* 1 */
  height: 0; /* 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
   ========================================================================== */
 
/**
 * Remove the gray background on active links in IE 10.
 */
a {
  background-color: transparent;
}
 
/**
 * 1. Remove the bottom border in Chrome 57-
 * 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 */
}
 
/**
 * 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 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: 0;
  position: relative;
  vertical-align: baseline;
}
 
sub {
  bottom: -0.25em;
}
 
sup {
  top: -0.5em;
}
 
/* Embedded content
   ========================================================================== */
 
/**
 * Remove the border on images inside links in IE 10.
 */
img {
  border-style: none;
}
 
/* Forms
   ========================================================================== */
 
/**
 * 1. Change the font styles in all browsers.
 * 2. Remove the margin in Firefox and Safari.
 */
button,
input,
optgroup,
select,
textarea {
  font-family: inherit; /* 1 */
  font-size: 100%; /* 1 */
  line-height: 1.15; /* 1 */
  margin: 0; /* 2 */
}
 
/**
 * 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;
}
 
/**
 * Correct the inability to style clickable types in iOS and Safari.
 */
button,
[type="button"],
[type="reset"],
[type="submit"] {
  -webkit-appearance: button;
}
 
/**
 * 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: 0;
}
 
/**
 * 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;
}
 
/**
 * Correct the padding in Firefox.
 */
fieldset {
  padding: 0.35em 0.75em 0.625em;
}
 
/**
 * 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: 0; /* 3 */
  white-space: normal; /* 1 */
}
 
/**
 * Add the correct vertical alignment in Chrome, Firefox, and Opera.
 */
progress {
  vertical-align: baseline;
}
 
/**
 * Remove the default vertical scrollbar in IE 10+.
 */
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: 0; /* 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 in Chrome and Safari on macOS.
 */
[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 Edge, IE 10+, and Firefox.
 */
details {
  display: block;
}
 
/*
 * Add the correct display in all browsers.
 */
summary {
  display: list-item;
}
 
/* Misc
   ========================================================================== */
 
/**
 * Add the correct display in IE 10+.
 */
template {
  display: none;
}
 
/**
 * Add the correct display in IE 10.
 */
[hidden] {
  display: none;
}

哪种CSS Reset最好

选择最好的 CSS Reset 取决于项目需求和个人偏好。

最适合的 CSS Reset 取决于你的项目需求。

如果你希望尽量保留默认样式并修复浏览器的不一致性,推荐使用 Normalize.css。

如果你更倾向于完全自定义样式,Eric Meyer’s Reset CSS 可能更适合。

而如果你想改变默认的盒模型计算方式,CSS Box Sizing Border Box 是一个很好的选择。

最重要的是,在使用任何 CSS Reset 方法之前,请确保你理解其工作原理,并测试其在你的项目中的效果。

参考文档:

  • https://www.zhankr.net/76634.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/838992.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

idea添加翻译插件并配置有道翻译

1、安装Translation插件 2、 创建有道云应用 有道智云控制台 3、设置idea 4、效果(选中文本右键翻译,默认快捷键CtrlShiftY)

OpenCV学习笔记--以车道线检测入门

本笔记gitee源代码: https://gitee.com/hongtao-jiang/opencv_lanedetect.git 2023.8.5 文章目录 1、OpenCV安装2、图片的读入、保存3、Canny算法边缘检测4、ROI mask5、霍夫变换6、离群值过滤7、最小二乘拟合8、直线绘制9、视频流读写 1、OpenCV安装 conda管理虚…

如何用限制立方样条(RCS)做生存分析?

一、引言 在医学和统计学领域,生存分析是一种分析个体生命长度和生存时间的重要方法。了解人们生存的期限和影响因素,对于制定健康政策、优化医疗资源的分配以及个体护理方案的制定都至关重要。传统的生存分析方法如Kaplan-Meier曲线和Cox比例风险模型已…

XXL-JOB定时任务框架(Oracle定制版)

特点 xxl-job是一个轻量级、易扩展的分布式任务调度平台,能够快速开发和简单学习。开放源代码并被多家公司线上产品使用,开箱即用。尽管其确实非常好用,但我在工作中使用的是Oracle数据库,因为xxl-job是针对MySQL设计的&#xff…

北邮22信通:第五章 图 最短路径 Dijkstra算法

北邮22信通一枚~ 跟随课程进度每周更新数据结构与算法的代码和文章 持续关注作者 解锁更多邮苑信通专属代码~ 获取更多文章 请访问专栏: 北邮22信通_青山如墨雨如画的博客-CSDN博客 一. 算法核心思想 Dijkstra算法是用来求取图中两个结点之间最短路径的算…

mysql大表的深度分页慢sql案例(跳页分页)

1 背景 有一张表,内容是 redis缓存中的key信息,数据量约1000万级, expiry列上有一个普通B树索引。 -- test.top definitionCREATE TABLE top (database int(11) DEFAULT NULL,type varchar(50) DEFAULT NULL,key varchar(500) DEFAULT NUL…

java+ssm校园高校足球联赛管理系统tdl2g

随着计算机技术发展,计算机系统的应用已延伸到社会的各个领域,大量基于网络的广泛应用给生活带来了十分的便利。所以把足球联赛管理与现在网络相结合,利用计算机搭建足球联赛管理系统,实现足球联赛管理系统的信息化。则对于进一步…

直线导轨在视觉检测设备中的应用

随着科技的不断发展,视觉检测设备已经逐渐代替了传统的人工品检,成为了工业生产中的一部分,在五金配件、塑胶件、橡胶件、电子配件等检测工业零部件表面外观缺陷尺寸方面应用,视觉检测设备具有优势。 直线导轨作为视觉检测设备中重…

EVE-NG MPLS L2VPN static lsp

目录 1 拓扑 2 配置步骤 2.1 配置接口IP 和路由协议 2.2 配置MPLS LDP 2.3 配置L2VPN PW 2.4 验证L2VPN 1 拓扑 2 配置步骤 2.1 配置接口IP 和路由协议 PE1 interface LoopBack 0ip address 1.1.1.9 32 quitinterface GigabitEthernet1/0ip address 10.1.1.1 255.255…

【数理知识】求刚体旋转矩阵和平移矩阵,已知 N>=3 个点在前后时刻的坐标,且这 N>=3 点间距离始终不变代表一个刚体

序号内容1【数理知识】自由度 degree of freedom 及自由度的计算方法2【数理知识】刚体 rigid body 及刚体的运动3【数理知识】刚体基本运动,平动,转动4【数理知识】向量数乘,内积,外积,matlab代码实现5【数理知识】协…

【深度学习_TensorFlow】感知机、全连接层、神经网络

写在前面 感知机、全连接层、神经网络是什么意思? 感知机: 是最简单的神经网络结构,可以对线性可分的数据进行分类。 全连接层: 是神经网络中的一种层结构,每个神经元与上一层的所有神经元相连接,实现全连接。 神经…

kibana-7.17.3版本安装及汉化

1、官网下载地址:https://www.elastic.co/cn/downloads/kibana 选择安装系统类型和历史版本kibana安装版本要和es版本对应 2、上传安装包然后解压 tar -zxf kibana-7.17.3-linux-x86_64.tar.gz 3、更改目录属主 chown elk. kibana-7.17.3-linux-x86_64 -R …

C语言笔试训练【第三天】

大家好,我是纪宁。 今天是C语言笔试训练的第三天,大家加油! 第一题 1、已知函数的原型是: int fun(char b[10], int *a) ,设定义: char c[10];int d; ,正确的调用语句是( &#xf…

基于Mediapipe的姿势识别并同步到Unity人体模型中

如题,由于是商业项目,无法公开源码,这里主要说一下实现此功能的思路。 人体关节点识别 基于Mediapipe Unity插件进行开发,性能比较低的CPU主机,无法流畅地运行Mediapipe,这个要注意一下。 Mediapipe33个人体…

STM32F103——基础篇

目录 1、寄存器基础知识 2、STM32F103系统架构 2.1 Cortex M3 内核&芯片 2.2 STM32F103系统架构 3、存储器映射 4、寄存器映射 4.1 寄存器描述解读 4.2 寄存器映射举例 4.3 寄存器地址计算 4.4 stm32f103xe.h 寄存器映射 1、寄存器基础知识 概念:寄存…

【C语言进阶】指针的高级应用(上)

本专栏介绍:免费专栏,并且会持续更新C语言基础知识,欢迎各位订阅关注。 关注我,带你了解更多关于机器人、嵌入式、人工智能等方面的优质文章,坚持更新! 大家的支持才是更新的最强动力! 文章目录…

详解PHP反射API

PHP中的反射API就像Java中的java.lang.reflect包一样。它由一系列可以分析属性、方法和类的内置类组成。它在某些方面和对象函数相似,比如get_class_vars(),但是更加灵活,而且可以提供更多信息。反射API也可与PHP最新的面向对象特性一起工作&…

掌握 JVM 的参数及配置

点击下方关注我,然后右上角点击...“设为星标”,就能第一时间收到更新推送啦~~~ JVM(Java虚拟机)是Java编程语言的核心组件之一,它负责执行Java程序,并提供一系列参数和配置选项,可以调整Java程…

探秘企业DevOps一体化平台建设终极形态丨IDCF

笔者从事为企业提供研发效能改进解决方案相关工作十几年,为国内上百家企业提供过DevOps咨询及解决方案落地解决方案,涉及行业包括:金融、通信、制造、互联网、快销等多种行业。 DevOps的核心是研发效能改进,效能的提升离不开强大…

Linux基本开发工具(一)

文章目录 Linux基本开发工具(一)Linux安装和卸载软件Linux 软件包管理器 yum关于sudo命令关于yum源的换源问题 vim编辑器的使用vim三种模式(常见)vim的基本操作vim配置 Linux基本开发工具(一) Linux安装和…