CSS:层叠样式表

层叠样式表 (CSS) 是一种 stylesheet 语言,用于描述以 HTMLXML(包括 SVGMathMLXHTML 等 XML 方言)编写的文档的表示形式。CSS 描述了元素如何在屏幕、纸张、语音或其他媒体上呈现。

¥Cascading Style Sheets (CSS) is a stylesheet language used to describe the presentation of a document written in HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS describes how elements should be rendered on screen, on paper, in speech, or on other media.

CSS 是开放 Web 的核心语言之一,并根据 W3C 规范 在 Web 浏览器中进行了标准化。此前,CSS 规范各个部分的开发是同步完成的,这允许对最新建议进行版本控制。你可能听说过 C、C.1,甚至 C。永远不会有 C 或 C;相反,现在一切都是 CSS,没有版本号。

¥CSS is among the core languages of the open web and is standardized across Web browsers according to W3C specifications. Previously, the development of various parts of CSS specification was done synchronously, which allowed the versioning of the latest recommendations. You might have heard about CSS1, CSS2.1, or even CSS3. There will never be a CSS3 or a CSS4; rather, everything is now CSS without a version number.

CSS 2.1 之后,规范的范围显着增加,不同 CSS 模块的进展开始差异很大,以至于到 每个模块单独开发和发布建议 变得更加有效。W3C 现在不再对 CSS 规范进行版本控制,而是定期拍摄 CSS 规范的最新稳定状态 和各个模块进度的快照。CSS 模块现在有版本号或级别,例如 CSS 颜色模块级别 5

¥After CSS 2.1, the scope of the specification increased significantly and the progress on different CSS modules started to differ so much, that it became more effective to develop and release recommendations separately per module. Instead of versioning the CSS specification, W3C now periodically takes a snapshot of the latest stable state of the CSS specification and individual modules progress. CSS modules now have version numbers, or levels, such as CSS Color Module Level 5.

关键资源

¥Key resources

CSS 简介

如果你是 Web 开发新手,请务必阅读我们的 CSS 基础知识 文章,了解 CSS 是什么以及如何使用它。

CSS 教程

我们的 CSS 学习区 包含丰富的教程,涵盖所有基础知识,可带你从初级水平到熟练程度。

CSS 参考

我们为经验丰富的 Web 开发者提供的 详尽的 CSS 参考 描述了 CSS 的每个属性和概念。

教程

¥Tutorials

我们的 CSS 学习区 具有多个模块,可以从头开始教授 CSS - 不需要任何先前的知识。

¥Our CSS Learning Area features multiple modules that teach CSS from the ground up — no previous knowledge required.

CSS 第一步

CSS(层叠样式表)用于设置网页的样式和布局 - 例如,更改内容的字体、颜色、大小和间距,将其拆分为多列,或添加动画和其他装饰功能。本模块为你掌握 CSS 之路提供了一个温和的开端,介绍了 CSS 的工作原理、语法是什么样子以及如何开始使用它向 HTML 添加样式的基础知识。

CSS 构建块

本模块从 CSS 第一步 结束的地方继续进行 - 现在你已经熟悉了该语言及其语法,并获得了一些使用它的基本经验,是时候更深入地研究了。该模块着眼于级联和继承、我们可用的所有选择器类型、单位、大小、背景和边框样式、调试等等。

这里的目的是为你提供一个用于编写合格 CSS 的工具包,并帮助你在继续学习 文本样式CSS 布局 等更具体的学科之前理解所有基本理论。

CSS 样式文本

介绍了 CSS 语言的基础知识后,你需要关注的下一个 CSS 主题是样式文本 — 这是你将使用 CSS 执行的最常见操作之一。在这里,我们了解文本样式的基础知识,包括设置字体、粗体、斜体、行距和字母间距、阴影和其他文本功能。我们通过将自定义字体应用到你的页面以及样式列表和链接来完善该模块。

CSS 布局

至此,我们已经了解了 CSS 基础知识、如何设置文本样式以及如何设置内容所在框的样式和操作。现在是时候看看如何将盒子放置在相对于视口以及彼此之间的正确位置。我们已经介绍了必要的先决条件,因此我们现在可以深入研究 CSS 布局,查看不同的显示设置、Flexbox、CSS 网格和定位等现代布局工具,以及你可能仍然想了解的一些遗留技术。

使用 CSS 解决常见问题

该模块提供了一些内容的链接,解释了如何使用 CSS 来解决创建网页时的常见问题。

参考

¥Reference

秘诀

¥Cookbook

CSS 布局秘诀 旨在汇集常见布局模式的秘诀,以及你可能需要在站点中实现的内容。除了提供可用作项目起点的代码之外,这些秘诀还强调了布局规范的不同使用方式以及作为开发者可以做出的选择。

¥The CSS layout cookbook aims to bring together recipes for common layout patterns, things you might need to implement in your sites. In addition to providing code you can use as a starting point in your projects, these recipes highlight the different ways layout specifications can be used and the choices you can make as a developer.

CSS 开发工具

¥Tools for CSS development

元错误

¥Meta bugs

也可以看看

¥See also