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

Deriving a set of variables from a single base variable


In Less, variables can be used to set other variables. This allows you to create sets of variables derived from a single variable. For instance, a variable set can define a color palette or a set of related dimensions. Mathematical operations, as described in the Creating complex relationships between properties recipe in Chapter 1, Getting to Grips with the Basics of Less, and the Less built-in functions, as described in Chapter 4, Leveraging the Less Built-in Functions, can be used to assign the derived variables.

Getting ready

In this recipe, you will change the look of a simple layout by changing one single variable value. You will need a valid HTML5 document that should include the less.js compiler and a Less file called project.less.

How to do it…

  1. You will first need to create a simple HTML5 file named index.html, as follows:

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
    
        <title>Use variables...