刚刚通过csslint运行了相当数量的css,主要是为了检查错误.我得到的80%警告来自多次定义相同的标题元素.所以我想知道清理这些风格的最佳方法是……
h4 {
color: red;
}
.archive h4 {
color: green;
}
请记住,我已经在设计的其他地方使用了h1 – h6样式.
为此使用类是否更好,然后使用mix-ins继承样式(我正在使用手写笔)?
h4 {
color: red;
}
.archive-header {
color: green;
}
虽然我在这,为什么csslint警告这个?有性能命中吗?
最佳答案 >为了解决它,确定…你的解决方案应该工作得很好.
> CSS Lint警告它,因为你不应该以不同的方式设置相同的标题.这是
article talking more about the subject的一点摘录:
When styling headings (or really anything) we want three big goals to be met:
- DRY – Do not repeat yourself. We want to set headings once and never (ok, rarely!) repeat those font styles or selectors. This will make our site easier to maintain.
- Predictable – The heading should look the same no matter where on the page it is placed. This will make creating new pages and content easier.
- Keep specificity low and selectors as simple as possible. This will help with performance and keep the site from growing more and more tangled over time.
>没有性能打击.如果有的话,使用类名而不是标签甚至可能是better.您提出的解决方案几乎是how to make your website faster by Google的教科书推荐.