Sass CSS预处理器深度解析

2 下载量 133 浏览量 更新于2024-09-01 收藏 114KB PDF 举报
"Sass是一款强大的CSS预处理器,它扩展了CSS的功能,包括变量、嵌套规则、混合、导入等,增强了CSS的编写效率和组织性。Sass有两种文件格式,scss和sass,推荐使用scss格式,因为它更接近标准CSS语法。此外,Sass与Less在编译环境、变量声明、条件语句支持、作用域和外部文件引用等方面存在差异。" Sass是CSS的增强工具,它的核心特点包括: 1. **完全兼容CSS3**:Sass编写的所有代码最终都会被编译成合法的CSS,因此你可以放心地使用所有CSS3特性。 2. **变量(Variables)**:Sass允许使用`$`符号定义变量,例如`$primary-color: #0982c1;`,之后可以在整个样式表中重用该颜色值。 3. **嵌套规则(Nested Rules)**:通过嵌套规则,可以将相关的CSS选择器组织在一起,使得代码更易读。例如: ```scss body { background: #eee; font-size: 12px; p { background: #0982c1; } } ``` 4. **混合(Mixins)**:混合允许创建可复用的代码块,可以包含任何CSS声明。它们可以带有参数,以提供更灵活的使用方式。 5. **函数(Functions)**:Sass提供了内置的函数,可以用于颜色值和属性值的计算。 6. **控制指令(Control Directives)**:类似编程语言的条件语句和循环,如`@if`, `@for`, `@while`等,增强了CSS的逻辑性。 7. **自定义输出格式**:Sass允许你定制输出的CSS格式,包括缩进、注释、空格等。 Sass有两种文件格式: - **.sass**:使用缩进表示代码块,没有大括号和分号,格式较为简洁但更严格。 - **.scss**:与标准CSS语法相似,使用大括号和分号,对初学者更友好。 在Sass和Less的对比中,有以下几点显著区别: - **编译环境**:Sass依赖于Ruby环境编译,而Less支持服务器端和客户端(浏览器)编译。 - **变量声明**:Sass使用`$`,Less使用`@`。 - **条件语句**:Sass支持更复杂的条件语句,Less的条件语句较简单。 - **作用域**:Sass的变量修改可以在局部影响全局,Less的变量具有局部作用域。 - **引用外部文件**:Sass引入文件时可忽略后缀,Less需要通过配置指定引入方式。 了解并熟练掌握Sass,可以帮助开发者编写出更加模块化、易于维护的CSS代码,提升工作效率。同时,结合Sass库(如Compass)可以进一步提升CSS设计的质量。
2009-09-03 上传
主要内容: l CPU's from the 8086/8088 to the Pentium III and Athlon l Real, protected and virtual models l Windows and plug&play devices l CPU Clones from all major manufacturers l Chipsets and support chips l Timers, interrupts and DMA l I/O programming and PCI bus programming l AGP variants and graphic systems l Universal serial bus l Local storage from the diskette to DVD l Memory systems, SDRAM, EDO, flas, RAM bus, and modules l Extensive glossary which explains most of the terms and concepts related to personal computer hardware. l Appendices brimming with practical advice, especially for programmers. ------------------------------------------------------------------------------------------------- 目录: Pearson Techonology Group - Indispensable PC Hardware Book, The Indispensable PC Hardware Book, The 4/e Hans-Peter Messmer Published January 2002 by Addison Wesley Professional Copyright 2002, 1296 pp., Cloth ISBN: 0-201-59616-4 Summary This fully revised and popular book is now up-to-date and even more comprehensive than before. The Indispensable PC Hardware Book 4/e will be 'indispensable' to anyone who wants to know more about the inner workings of a personal computer: from programmers who want access to hardware components; professionals and home-users who wants to or has to understand the structure and functioning of a personal computer; to users who want to up-grade their PC's, and dealers who wish to advise their customers--this book will provide the solution to all your hardware questions. Even beginners should not shy away as this book begins with an easy introduction to the subject area. Key highlights: l CPU's from the 8086/8088 to the Pentium III and Athlon l Real, protected and virtual models l Windows and plug&play devices l CPU Clones from all major manufacturers l Chipsets and support chips l Timers, interrupts and DMA l I/O programming and P