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

Identifying patterns in your CSS


Identifying patterns in your CSS is all about asking yourself one question: how can I reduce code?

There are a number of ways of doing this; the exact process will depend on the nature of the site being converted. There are some general questions that you can ask yourself though, to help with the conversion process:

  • Does your site use any CSS3 styles? If it does, consider using a prebuilt Less library, which we can import in our Less style sheet.

  • Does your CSS code contain any statements, such as links to image elements? If it does, you might want to consider using string variables and interpolation to better manage the links, particularly if they need to be updated in the future.

  • How many variables does your site use? If any of these variables will be used to define colors, then consider using some of Less' in-built functions or operators to dynamically generate colors, such as making a color lighter by 20 percent or adding a value to an existing color to create...