CSS 重置 - 它究竟是做什么的? [英] CSS reset - What exactly does it do?

查看:26
本文介绍了CSS 重置 - 它究竟是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 jquery 图像滑块演示中发现了这个 reset.css 文件,但它从未包含在主 index.html 文件中.什么是假设,更重要的是,你把它放在哪里?您是否将它放在任何引用的样式表()之前?

I found this reset.css file inside a jquery image slider demo, but it was never included in the main index.html file. what is is suppose to do, and more importantly, where do you put it? Do you put it before any referenced stylesheets()?

这是reset.css里面的代码

Here is the code inside reset.css

/* CSS reset */
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { 
    margin:0;
    padding:0;
}
html,body {
    margin:0;
    padding:0;
}
table {
    border-collapse:collapse;
    border-spacing:0;
}
fieldset,img { 
    border:0;
}
input{
    border:1px solid #b0b0b0;
    padding:3px 5px 4px;
    color:#979797;
    width:190px;
}
address,caption,cite,code,dfn,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:0;
}

推荐答案

一开始,样式如何工作没有标准化,每个浏览器都实现了它认为正确的东西.您在 IE 中看到如此多关于样式错误的问题的原因之一是因为 IE 是与其他浏览器在样式方面最不相似的浏览器.尽管 IE 和其他浏览器都得到了改进,但它们仍然对元素应用自己的边框、填充和边距、缩放、字体,以赋予页面自己独特的感觉.一个例子是,chrome 为文本框提供了自己的黄色边框.重置"实际上重置"所有这些样式都为零/无,这样您就看不到任何未应用于页面的样式.

In the beginning, there was no standardisation on how styles worked, each browser implemented what it felt was right. One of the reasons you see so many questions about style errors in IE is because IE was the browser with the most dissimilarities from other browsers in terms of styling. Though IE has improved and so have other browsers they still apply their own borders, padding and margins, zoom, fonts to elements to give their own unique feel to pages. One example is, chrome gives its own yellow borders to text boxes. The "reset" actually "resets" all these styles to zero/none, so that you don't see any styles you haven't applied to your page.

如果这些样式没有重置",您将看到不需要的样式/效果和破坏.它通常建议重置"浏览器的样式.

If these styles are not "reset", you will see unwanted styles/effects and things breaking. Its generally recommended to "reset" the browser's styles.

看看这篇文章你应该重置你的 CSS 吗?

这篇关于CSS 重置 - 它究竟是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆