css 错误检查
I've always taken a lot of pride in the fact that I've taught myself most of what I know. It started when I was 13 and taught myself HTML, then CSS, then JavaScript, then PHP, and the process continues today with MooTools, jQuery, and whatever else comes my way. I'd be lying if I said I didn't learn some things the hard way though. Have a chuckle at some of my past CSS mistakes.
我一直以自己所学的大部分知识为荣,对此我一直感到非常自豪。 它始于我13岁的时候,自学HTML,CSS,JavaScript,PHP,直到今天,MooTools,jQuery和其他任何方式都可以继续学习。 如果我说我没有努力学习一些东西,那我会撒谎。 嘲笑我过去的一些CSS错误。
* {font-size:11px; } (* { font-size:11px; })
Setting the font-size property within the "*" selector was a huge mistake on my early websites. Nesting tags would result in a reset font-size, so in some cases I had to duplicate font-size declarations inline. Painful to look at old sites with this.
在我早期的网站上,在“ *”选择器中设置font-size属性是一个巨大的错误。 嵌套标签会导致重置字体大小,因此在某些情况下,我必须内联重复字体大小声明。 痛苦地看着这个旧站点。
<p class="bigger">I wish you would <a href="https://davidwalsh.name" class="bigger">click here</a>.
* {颜色:#000; } (* { color:#000; })
Another case of placing a property within the "*" that I shouldn't have. I'd again need to duplicate inline-styling efforts when nesting tags.
在我不应该在“ *”中放置属性的另一种情况。 嵌套标签时,我再次需要重复内联样式的工作。
长CSS声明 (Long CSS Declarations)
When I first started with CSS, I didn't know any shorthand CSS. Unfortunately, my classes would end up looking like:
刚开始使用CSS时,我不知道任何速记CSS。 不幸的是,我的课程最终看起来像:
.my-div { margin-right:20px; margin-left:20px; margin-top:3px; }
Shorthanded declarations have made CSS life much easier.
简化的声明使CSS的工作变得更加轻松。
长CSS颜色 (Long CSS Colors)
When I see some of my old stylesheets, they're full of long color declarations, like:
当我看到一些旧样式表时,它们充满了长长的颜色声明,例如:
.my-div { color:#000000; background:#ffffff; border-bottom:#ff0000; }
Of course, the above should look like:
当然,上面应该看起来像:
.my-div { color:#000; background:#fff; border-bottom:#f00; }
多行CSS声明 (Multi-Line CSS Declarations)
Some of my old stylesheets look eight miles long. There's a huge difference in maintainability between a 10 lines and one:
我的一些旧样式表看起来长八英里。 10条线和一条线之间在可维护性方面存在巨大差异:
/* too long */
p
{
font-size:12px;
line-height:19px;
color:#999;
margin:0 0 5px 0;
padding:0 0 15px 0;
text-indent:20px;
font-family:arial, verdana, sans-serif;
}
/* much better! */
p { font-size:12px; line-height:19px; color:#999; margin:0 0 5px 0; padding:0 0 15px 0; text-indent:20px; font-family:arial, verdana, sans-serif; }
So those are the ghosts in my CSS closet. What CSS practices do you regret today?
这些就是我CSS壁橱中的幽灵。 您今天后悔什么CSS做法?
css 错误检查