Book Image

Learning less.js

Book Image

Learning less.js

Overview of this book

Table of Contents (22 chapters)
Learning Less.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Exploring mixins


When writing code, how many times have you written a similar code, but for different projects? Ever wondered if you could, with a little change in the writing style, convert to using prebuilt blocks of CSS that you can drop in a project at a moment's notice?

Sure, you could start to create your own library of code—this would work perfectly well. However, it suffers from at least one potential drawback: you will very likely have to manually modify any stored code to fit the needs of a new project. While this will work, you might find yourself expending more time updating code than if it had been written from scratch!

What if I said you could still maintain a code library, but you don't have to keep modifying each block of library code that you reuse? It is possible—with the use of Less' mixin functionality.

Mixins are blocks of code that do as the name suggests—they can be mixed-in to your project code and called when required. They can even be moved to a library style sheet...