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

Creating color objects with RGB values


In this recipe, you will create some color objects with the rgb() color definition function.

Getting ready

For this recipe, you can use your favorite text editor and the command-line lessc compiler, as described in the Installing the lessc compiler with npm recipe in Chapter 1, Getting to Grips with the Basics of Less. Also, looking at the color equivalents table at http://meyerweb.com/eric/css/colors/ will be useful. This table will give you an insight into the relation between the different color definitions available in CSS3.

How to do it…

  1. Create a colors.less file and write down the following Less code into it:

    colors {
      color1: rgb(255,0,0); //red
      color2: rgb(100%,0,0); //red
      color3: rgb(255,255,0); //yellow
      color4: rgb(100%,100%,0); //yellow
      color5: rgb(255,99,71); //tomato
      color6: rgb(100%,38.8%,27.8%); //tomato
    }
  2. After the compilation of the preceding Less code, your final CSS code will look like the following code:

    colors {
      color1: #ff0000...