本篇文章给大家带来的内容是介绍css怎么重置样式,总结了一些常用css默认样式重置的代码分享给大家。有一定的参考价值,有需要的朋友可以参考一下,希望对你们有所帮助。
在网页设计开发时,让人最头疼的莫过于让页面兼容各大浏览器,准确些是兼容它们“默认”的CSS样式表。那么,“抹掉”这些css默认样式表成了首要问题,也就有了CSS默认样式表重置一说。为了让页面在各不同浏览器之间显示效果一致,清除和重置css默认样式就变成必需要做的事情了。
下面就给大家分享一些常用css默认样式重置代码,仅供大家参考。
1、css初始化标签在所有浏览器中的margin、padding值(内外边距)
1 2 3 4 5 6 7 8 | body, h1, h2, h3, h4, h5, h6, hr, p, blockquote,
dl, dt, dd, ul, ol, li,
pre,
form, fieldset, legend, button, input, textarea,
th, td {
margin: 0;
padding: 0;
}
|
登录后复制
2、css重置页面元素样式
1 2 3 4 5 6 7 8 9 10 11 12 13 | body {background:#fff}
body,th,td,input,select,textarea,button {
font-size:12px;line-height:1 ;font-family: "微软雅黑" , "黑体" , "宋体" ;color:#666;
}
h1 { font-size: 18px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
h4, h5, h6 { font-size: 100%; }
address,caption,cite,code,dfn,em, var {font-style:normal;font-weight:normal}
code, kbd, pre, samp { font-family: courier new , courier, monospace; }
small { font-size: 12px; }
|
登录后复制
3、css重置列表元素样式
1 | dl,ul,ol,menu,li {list-style:none}
|
登录后复制
4、 css重置文本格式元素样式(鼠标效果)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | a {color:#666;text-decoration:none}
a:active, a:hover {text-decoration:none}
a {outline: none;}
a:active {star:expression(this.onFocus=this.blur());}
|
登录后复制
5、css重置表单元素样式
1 2 3 4 5 6 7 8 9 10 11 12 | legend { color: #000; }
fieldset,img {border:0 none}
button, input, select, textarea {
font-size: 100%;
vertical-align:middle;
}
button {border:0 none;background-color:transparent;cursor:pointer}
img{vertical-align:top}
|
登录后复制
6、css重置表格元素样式
1 2 | caption {display:none;}
table {width:100%;border-collapse:collapse;border-spacing:0;table-layout:fixed;}
|
登录后复制
7、清除浮动
1 2 3 4 5 6 | .clear{clear: both;}
.clearfix:before,.clearfix:after{content: '';display: table;}
.clearfix:after{clear: both;}
|
登录后复制
8、css重置嵌套引用
1 2 | blockquote, q {quotes: none}
blockquote:before, blockquote:after,q:before, q:after {content:'';content:none}
|
登录后复制
总结:以上就是本篇文章所总结的常用css重置默认样式的全部代码, 大家可以自己动手尝试,加深理解。希望能对大家的学习有所帮助,更多相关教程请访问: CSS基础视频教程, HTML视频教程,bootstrap视频教程!
以上是css怎么重置样式?网页中8种css默认样式重置代码汇总的详细内容。更多信息请关注PHP中文网其他相关文章!