Book Image

Sass and Compass Designer's Cookbook

By : Bass Jobsen, Stuart Robson
Book Image

Sass and Compass Designer's Cookbook

By: Bass Jobsen, Stuart Robson

Overview of this book

Sass and Compass Designer's Cookbook helps you to get most out of CSS3 and harness its benefits to create engaging and receptive applications. This book will help you develop faster and reduce the maintenance time for your web development projects by using Sass and Compass. You will learn how to use with CSS frameworks such as Bootstrap and Foundation and understand how to use other libraries of pre-built mixins. You will also learn setting up a development environment with Gulp. This book guides you through all the concepts and gives you practical examples for full understanding.
Table of Contents (23 chapters)
Sass and Compass Designer's Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Leveraging mixins


Mixins play an important role in Sass and help you write reusable code and use semantic HTML code.

Mixins are like macros and allow you to reuse properties and selectors. People used to functions programming will tend to see mixins like functions. Mixins do not return a value at runtime, but generate an output at compile time. For functions in Sass, read the Creating pure Sass functions recipe of this chapter.

Getting ready

You can test the mixins in this recipe with the Ruby Sass compiler. The Installing Sass for command line usage recipe of Chapter 1, Getting Started with Sass, describes how to install Ruby Sass on your system.

How to do it...

The steps beneath will help you to understand how to use mixins in your Sass code:

  1. Create a Sass project file, which contains the following code:

     @import 'components/responsive-utilities'; 
    
    // scss-lint:disable ColorKeyword 
    $side-bar-background-color: orange !default; 
    
    .side-bar { 
      @include hidden-mobile; 
      
      background-color:...