0
点赞
收藏
分享

微信扫一扫

Java设计之道:色即是空,空即是色

斗米 04-03 12:00 阅读 1
css前端

01 A Brief History of (Web) Style

CSS网页布局权威指南01 (网络)样式简史

CSS was first proposed in 1994, just as the web was beginning to really catch on. At the time, browsers gave all sorts of styling power to the user—the presentation preferences in NCSA Mosaic, for example, permitted the user to define each element’s font family, size, and color. None of this was available to document authors; all they could do was mark a piece of content as a paragraph, as a heading of some level, as preformatted text, or one of a dozen other element types. If a user configured their browser to make all level-one headings tiny and pink and all level-six headings huge and red, well, that was their lookout.

CSS最早是在1994年提出的,当时网络刚刚开始流行起来。当时,浏览器为用户提供了各种样式功能——例如,NCSA Mosaic中的表示首选项允许用户定义每个元素的字体系列、大小和颜色。这些都不是文档作者可以得到的;他们所能做的就是将一段内容标记为段落,标记为某种级别的标题,标记为预格式化的文本,或标记为其他十几种元素类型之一。如果用户将浏览器设置为所有一级标题都是粉红色的小标题,而所有六级标题都是红色的大标题,那就是他们的问题了。

It was into this milieu that CSS was introduced. Its goal was to provide a simple, declarative styling language that was flexible for web page authors and, most importantly, provided styling power to authors and users alike. By means of the cascade, these styles could be combined and prioritized so that both site authors and readers had a say—though readers always had the last say.

CSS就是在这种环境下被引入的。它的目标是为网页作者提供一种简单的、声明式的样式语言,这种语言非常灵活,最重要的是,为作者和用户提供样式功能。通过层叠的方式,这些样式可以组合起来并优先排序,这样网站作者和读者都有发言权——尽管读者总是最后说了算。

Work quickly advanced, and by late 1996, CSS1 was finished. While the newly established CSS Working Group moved forward with CSS2, browsers struggled to implement CSS1 in an interoperable way. Although each piece of CSS was fairly simple on its own, the combination of those pieces created some surprisingly complex behaviors. Unfortunate missteps also occurred, such as the infamous discrepancy in box model implementations. These problems threatened to derail CSS altogether, but fortunately some clever proposals were implemented, and browsers began to harmonize. Within a few years, thanks to increasing interoperability and high-profile developments such as the CSS-based redesign of Wired magazine and the CSS Zen Garden, CSS began to catch on.

工作进展迅速,到1996年底,CSS1完成了。当新成立的CSS工作组继续推进CSS2时,浏览器却在努力以一种可互操作的方式实现CSS1。尽管每一块CSS本身都相当简单,但这些部分的组合创造了一些令人惊讶的复杂行为。不幸的错误也发生了,比如盒子模型实现中臭名昭著的差异。这些问题威胁到CSS的发展,但幸运的是,一些聪明的建议被实现了,浏览器开始协调一致。在几年之内,由于互操作性的提高和高调的发展,如基于CSS的Wired杂志的重新设计和CSS禅宗花园,CSS开始流行起来。

Before all that happened, though, the CSS Working Group had finalized the CSS2 specification in early 1998. Once CSS2 was finished, work immediately began on CSS3, as well as a clarified version of CSS2 called CSS2.1. In keeping with the spirit of the times, what was initially coined CSS3 was constructed as a series of (theoretically) standalone modules instead of a single monolithic specification. This approach reflected the then-active XHTML specification, which was split into modules for similar reasons.

在这一切发生之前,CSS工作组在1998年初完成了CSS2规范。一旦CSS2完成,CSS3的工作立即开始,以及CSS2的澄清版本CSS2.1。为了与时代精神保持一致,最初创造的CSS3被构建为一系列(理论上)独立的模块,而不是单一的整体规范。这种方法反映了当时流行的XHTML规范,由于类似的原因,XHTML规范被分成了几个模块。

The rationale for modularizing CSS was that each module could be worked on at its own pace, and particularly critical (or popular) modules could be advanced along the World Wide Web Consortium’s (W3C’s) progress track without being held up by others. Indeed, this has turned out to be the case. By early 2012, three CSS Level 3 modules (along with CSS1 and CSS 2.1) had reached full Recommendation status—CSS Color Level 3, CSS Namespaces, and Selectors Level 3. At that same time, seven modules were at Candidate Recommendation status, and several dozen others were in various stages of Working Draft-ness. Under the old approach, colors, selectors, and namespaces would have had to wait for every other part of the specification to be done or cut before they could be part of a completed specification. Thanks to modularization, they didn’t have to wait.

模块化CSS的基本原理是,每个模块都可以按照自己的进度进行工作,特别是关键的(或流行的)模块可以沿着万维网联盟(W3C)的进度轨道推进,而不会被其他模块阻碍。事实上,事实证明确实如此。到2012年初,三个CSS 3级模块(以及CSS1和css2.1)已经达到了完全的推荐状态——CSS颜色3级、CSS命名空间和选择器3级。同时,有7个模块处于候选建议状态,另有几十个模块处于工作草案的不同阶段。在旧的方法下,颜色、选择器和名称空间必须等待规范的其他部分完成或删除,才能成为完整规范的一部分。由于模块化,他们不必等待。

So while we can’t really point to a single tome and say, “This is CSS,” we can talk of features by the module name under which they are introduced. The flexibility permitted by modules more than makes up for the semantic awkwardness they sometimes create. (If you want something approximating a single monolithic specification, the CSS Working Group publishes yearly “Snapshot” documents.)

因此,虽然我们不能指着某一本书说,“这就是CSS”,但我们可以通过引入这些特性的模块名称来谈论这些特性。模块所允许的灵活性远远弥补了它们有时造成的语义上的尴尬。(如果你想要一个近似于单一整体规范的东西,CSS工作组每年都会发布“快照”文档。)

With that established, we’re ready to start understanding CSS. Let’s start by covering the basics of what goes inside a stylesheet.

有了这些,我们就可以开始理解CSS了。让我们从介绍样式表内部的基本内容开始。

举报
0 条评论