重置html代码怎么写,HTML_css reset重置基础代码,cssreset,即重置css,也就是重 - phpStudy...

本文介绍了CSS Reset的基本概念,探讨了为何重置浏览器默认样式,并提供了几种常见的CSS Reset代码示例,如Eric Meyer和Yahoo's YUI的方法,以减少代码冗余,确保跨浏览器一致性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

css reset重置基础代码

cssreset,即重置css,也就是重置默认样式。在不同浏览器,HTML中标签的默认样式有一个默认属性值,渲染出来的效果不尽相同,我们在写css页面的时候,为了避免在css中重复定义它们,我们需要重置默认样式,以方便统一,从而提高开发效率,提高样式代码的重用,减少重复代码,减少维护成本。

一般调页面的时候都写个:

*{margin:0;padding:0;}

方便简洁,但是实际的项目就不要这么写了,因为“*”是全局的意思,即全部标签都要运行这么一句东西,这样开销就大了,一般是采用按所需标签陈列的方式,你用哪些就写哪些,如下:

body,form,div,span,ul,ol,li{margin:0;padding:0;}

下面的是我目前用到的reset

body,form,div,span,ul,ol,li,p,pre,dl,dt,dd,h1,h2,h3,h4,h5,h6,em,a,fieldset,legend,address,label,textarea,select,input,figure,table,th,td,b,i{margin:0;padding:0;}

fieldset,img{border:0;}

ul,li{list-style:none;}

em,i{font-style:normal;}

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

a{text-decoration:none;}

a:hover{text-decoration:underline;}

a:focus,input,button,select,textarea{outline:none;}

h1,h2,h3,h4,h5,h6{font-size:100%;font-variant:normal;}

input,select,img{vertical-align:middle;}

legend{display:none;}

textarea{resize:none;}

.clear{clear:both;}

.clearfix{zoom:1;}

.clearfix:after{clear:both;content:"";display:block;height:0;line-height:0;visibility:hidden;}

下面是EricMeyer的

html,body,div,span,applet,object,iframe,table,caption,

tbody,tfoot,thead,tr,th,td,del,dfn,em,font,img,ins,

kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,

h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,

acronym,address,big,cite,code,dl,dt,dd,ol,ul,li,

fieldset,form,label,legend{

vertical-align:baselinebaseline;

font-family:inherit;

font-weight:inherit;

font-style:inherit;

font-size:100%;

outline:0;

padding:0;

margin:0;

border:0;

}

:focus{

outline:0;

}

body{

background:white;

line-height:1;

color:black;

}

ol,ul{

list-style:none;

}

table{

border-collapse:separate;

border-spacing:0;

}

caption,th,td{

font-weight:normal;

text-align:left;

}

blockquote:before,blockquote:after,q:before,q:after{

content:"";

}

blockquote,q{

quotes:"""";

}

下面是Yahoo’s(YUI)CSSReset

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,

form,fieldset,input,textarea,p,blockquote,th,td{

padding:0;

margin:0;

}

table{

border-collapse:collapse;

border-spacing:0;

}

fieldset,img{

border:0;

}

address,caption,cite,code,dfn,em,strong,th,var{

font-weight:normal;

font-style:normal;

}

ol,ul{

list-style:none;

}

caption,th{

text-align:left;

}

h1,h2,h3,h4,h5,h6{

font-weight:normal;

font-size:100%;

}

q:before,q:after{

content:'';

}

abbr,acronym{

border:0;

}相关阅读:

PHP冒泡排序算法代码详细解读

jsp Hibernate 函数简介

Centos安装桌面一键包

11款基于Javascript的文件管理器

用javascript获得地址栏参数的两种方法

DataGrid连接Access的快速分页法 5

PHP测试程序运行时间的类

PHP 5.3.1 安装包 VC9 VC6不同版本的区别是什么

js漂浮广告代码,静止浮动与右下角浮动(兼容多浏览器)

Ajax 返回字符串的过滤实现代码

PHP网站修改代码做好301重定向

Web的真谛:HTML5到底是什么意思

剖析JSP与XML的交互编程技巧

合并table相同单元格的jquery插件分享(很精简)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值