Coyier CSS 入门套件
I felt called out by Mike Mai’s You are not a CSS dev if you have not made a CSS reset.
Mike Mai 的 如果你没做过 CSS reset,你就不是 CSS 开发者 让我感觉被点名了。
I hadn’t! I mean, I’ve used * { box-sizing: border-box; }
a ton and, way back, I used to use that same universal selector to wipe away margins and padding, which was the inspiration behind the CSS-Tricks logo, believe it or not.
我没有!我是说,我用过 * { box-sizing: border-box; }
很多次,而且很久以前,我也曾用同样的通配选择器把 margin 和 padding 清零,信不信由你,这成了 CSS-Tricks 标志的灵感来源。
But I never made or published anything and planted a stake in the ground and said “This one. This one is mine.”
但我从未真正做出或发布过什么,然后立下一根桩子说:“这个。这个是我的。”
So I’m going to do that.
所以我要这么做。
First, I think it’s important to lay some ground rules. Some principles, really. There are a lot of directions a thing like this can go, and without what it’s for (and not for) it’s fairly useless.
首先,我认为设定一些基本规则很重要。实际上是一些原则。这类事情有很多可能的方向,如果没有明确它的用途(以及不用于什么),它就毫无用处。
- This is for me. The styles in here are useful to me. They are things I find myself doing very often (or forgetting to do.) I’d like to be using this in most demos I make and dipping into it for any future project. I do hope y’all will find some value in it too of course, hence blogging about it, but as a guiding principal it’s for me.
- 这是给我自己用的。 这里的样式对我有用。它们是我经常做的事(或经常忘记做的事)。我希望在大多数演示中使用它,并在未来的任何项目中随时取用。我当然也希望你们也能从中找到价值,所以才写博客分享,但作为一个指导原则,它是为我而设。
- This is not a reset, it’s an opinionated starter. I’m not trying to wipe out all existing styles from user-agent stylesheets. I wipe out the ones that are useful for me to remove. It’s more about adding useful styles, improving UX broadly, and fixing common issues.
- 这不是一次重置,而是一种有主见的起点。我并非试图抹去用户代理样式表中所有的既有样式,而是清除那些对我来说有必要移除的部分。它更侧重于添加有用的样式、提升整体用户体验,以及修复常见问题。
- Use only logical properties. It’s a net gain.
- 只用逻辑属性。 这是纯收益。
-
Don’t use
--custom-properties
. Setting those up is a step too far for this starter. Use Open Props for that sort of thing. -
不要使用
--custom-properties
。 设置这些对这个起步模板来说有点过。想用这类东西就用 Open Props。 -
Use
@layer
because “you’ll need to do it anyway if yo...