- 翻译本页下面全部内容，下载Chapter 1并翻译前15页。
Just a few short years ago, the idea of a book on Sass or Compass seemed absurd. As early adopters, we knew we had seen the future of stylesheet authoring, but we struggled to gain much traction outside the Ruby community in which Sass was born. Developers often didn’t see the dichotomy of using frameworks to create dynamic web pages while still writing static CSS by hand. Yet others were distrustful of Sass’s only syntax at the time, the original indented, whitespace-significant syntax. It felt too rigid, like too much of a departure from CSS.
In 2010, as we worked to evangelize the benefits of Sass to our designer friends across the industry (and making some converts, we should add), Sass and the idea of preprocessed CSS began to get a foothold in development and designer circles. When Sass introduced the SCSS syntax, many of the objections to adopting Sass began to fade away and we saw a real tipping point in projects using Sass for stylesheet authoring.
At the time, many other languages with a similar vision were emerging. Much like Sirius and XM validated the idea of satellite radio, healthy competition helped validate the idea of preprocessed CSS. It was in this environment of initial industry curiosity that Manning approached us to write a book about Sass and Compass. We agreed to write this book because we wanted to share Sass with a broader audience. While it’s taken much longer to produce than we wanted due to career moves and major life events for each of us, we’re excited to offer this book to the community that has grown up around Sass.
If you’re new to Sass, we hope it provides a solid foundation for the language and opens your eyes to new techniques. Even if you’ve been writing Sass for many years, we’re confident you’ll deepen your understanding of advanced Sass and Compass features that you’ll take back to your own projects.
about this book
So many of us pick up techniques from the community, learning stylesheet hacks and other tricks in short-form blog posts or screencasts. This book aims to present a topdown survey of two tools—Sass and Compass—to expand your CSS toolkit and make you a better stylesheet author. While focusing on practical application, we take a systematic approach to teaching Sass syntax and applying the patterns in the Compass framework. Hopefully, the reader will walk away with a more complete understanding of both Sass and Compass.
This book is designed for two main audiences. First, we want to reach out to web designers, those who write a lot of CSS but might not have considered ways to automate parts of the stylesheet authoring process. Second, we want to show full stack developers how to treat stylesheets, images, and fonts like any other project asset and how to handle them throughout the lifecycle of a project from development to production.
If you’re new to Sass and Compass, you might find yourself jumping to appendixes A and B as you begin the book. Those appendixes provide setup instructions and other prerequisites you’ll need for the book.
Chapter 1 dives right into the powerful features of the Sass language. You’ll discover not only exciting features, but hopefully a renewed joy for CSS when the tedium of static stylesheets disappears. We’ll also give you a taste of the Compass framework in examples that provide practical application of Sass’s features.
Chapter 2 goes deeper into Sass and covers variables, mixins, and other language features that provide the building blocks for the rest of the book.
Chapter 3 jumps right into one of the most common uses for CSS, building grid systems. As you’ll see, with Sass, there’s far less math involved.
Chapter 4 takes a step back to give a broader view of how the Compass framework can reduce the mundane tasks that come with stylesheet authoring.
In Chapter 5, we take a survey of Compass’s CSS3 module and how it provides vendor-independent implementation of the most commonly used aspects of CSS3.
Chapter 6 is a fun experiment with CSS sprites, an advanced technique every designer should know.
Chapter 7 demonstrates how to optimize your stylesheets for both development debugging and production deployment using Compass’s compile features. Chapter 8 builds on this theme and shows advanced techniques to compress and minify your stylesheet assets for deployment.
Chapter 9 is aimed at the advanced developer who would like to use Sass’s advanced scripting techniques. Chapter 10 expands on this topic and walks you through creating your own Compass plugin.