CSS(层叠样式表)
CSS 是控制网页视觉表现的语言 — 包括布局、颜色、字体、间距、动画和响应式设计。每个网站都使用 CSS 搭配 HTML,它是创建现代、可访问且视觉美观的用户界面所必不可少的。
MIME 类型
text/css
类型
文本
压缩
无损
优点
- + Separates presentation from content (HTML)
- + Powerful layout systems: Flexbox, Grid, and container queries
- + Custom properties enable theming and dynamic values
- + Media queries enable responsive design for all screen sizes
缺点
- − Global scope can cause unintended style conflicts
- − Browser compatibility differences require testing
- − No native variables before custom properties (pre-2017)
何时使用 .CSS
在所有网页样式中使用 CSS,从简单的排版到复杂的布局和动画。
技术细节
CSS 使用选择器定位 HTML 元素,使用声明块应用样式。层叠、优先级和继承规则决定哪些样式生效。现代 CSS 包括 Flexbox、Grid、自定义属性(变量)和容器查询。
历史
Hakon Wium Lie 于 1994 年在 CERN 提出了 CSS。CSS1 于 1996 年发布,CSS2 于 1998 年发布,CSS3 从 1999 年开始引入模块化规范。Grid、Flexbox 和自定义属性等现代 CSS 特性持续演进。
从 .CSS 转换
转换为 .CSS
相关格式
相关术语
Learn More
CSS Units Explained: px, em, rem, vh, and When to Use Each
CSS offers over a dozen length units, each suited to different situations. Understanding the differences between absolute and relative units …
JSON vs YAML vs TOML: Choosing a Configuration Format
Configuration files are the backbone of modern applications. JSON, YAML, and TOML each offer different trade-offs between readability, complexity, and …
Flexbox vs CSS Grid: A Practical Comparison
Flexbox and CSS Grid are complementary layout systems, not competitors. This guide clarifies when to reach for each one and …
How to Format and Validate JSON Data
Malformed JSON causes silent failures in APIs and configuration files. Learn how to format, validate, and debug JSON documents to …
Base64 Encoding: How It Works and When to Use It
Base64 converts binary data into ASCII text, making it safe for transmission through text-based systems. Learn when Base64 is the …
How to Create CSS Gradients: Linear, Radial, and Conic
CSS gradients create smooth color transitions without image files. Learn to build linear, radial, and conic gradients with precise control …