Book Image

LESS WEB DEVELOPMENT COOKBOOK

Book Image

LESS WEB DEVELOPMENT COOKBOOK

Overview of this book

Table of Contents (19 chapters)
Less Web Development Cookbook
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Aggregating values under a single property


The merge feature of Less enables you to merge property values into a list under a single property. Each list can be either space-separated or comma-separated. The merge feature can be useful to define a property that accepts a list as a value. For instance, the background accepts a comma-separated list of backgrounds.

Getting ready

For this recipe, you will need a text editor and a Less compiler. In Chapter 1, Getting to Grips with the Basics of Less, you can read how to use and install the less.js client-side or command-line lessc compiler.

How to do it…

  1. Create a file called defaultfonts.less that contains the following Less code:

    .default-fonts() {
      font-family+:  Helvetica, Arial, sans-serif;
    }
    p {
      font-family+: "Helvetica Neue";
      .default-fonts();
    }
  2. Compile the defaultfonts.less file from step 1 using the following command in the console:

    lessc defaultfonts.less
    
  3. Inspect the CSS code output on the console after compilation and you will see that...