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

Getting information about a color


As you can read in the recipe, colors are defined with different channels. Less provides you with some functions to get information about a channel that belongs to a certain color definition.

Getting ready

This recipe will only give you a small piece of example Less code. You can compile this example Less code with the client-side or server-side compiler, as described in Chapter 1, Getting to Grips with the Basics of Less, and inspect the compiled CSS code.

How to do it…

  1. Compile the following Less code into CSS using a Less compiler:

    hsv {
      hsvvalue: hsvvalue(hsv(90, 100%, 50%));
      color: hsv(90, 100%, 50%);
    }
    rgb {
      hsvvalue: hsvvalue(#408000);
    }
  2. You will find that the preceding Less code will compile into the following CSS code:

    hsv {
      hsvvalue: 50%;
      color: #408000;
    }
    rgb {
      hsvvalue: 50%;
    }

How it works…

Colors are defined with channels; the value set by the channel depends on the color definition. RGB colors have a red, green, and blue channel, and HSL...