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

Extending with the all keyword


The all keyword can be added at the end of the extend argument to match all the instances of the selector. In this recipe, you can find that all the instances of a selector include merged and nested selectors. The all keyword can also be used to extend pseudo classes that are nested with the &:pseudoclass syntax, as discussed in the Referencing parent selectors with the & operator recipe.

Getting ready

You can compile the Less code in this recipe with 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. Use your favorite text editor to create and edit an example Less file called all.less.

How to do it…

  1. Write the following Less code into an all.less file:

    a.red-link {
      color:red;
      &:hover {
        color: lighten(red,20%);
      }
    }
    a.another:extend(a.red-link){}
    a.another-withhover:extend(a.red-link all){}
    .link--error:extend(.red-link){} 
    .link-all--error...