Book Image

Less Web Development Essentials

By : Bass Jobsen
Book Image

Less Web Development Essentials

By: Bass Jobsen

Overview of this book

Less is a CSS preprocessor that essentially improves the functionality of simple CSS with the addition of several features. The book begins by teaching you how Less facilitates the process of web development. You will quickly then move on to actually creating your first layout using Less and compiling your very first Less code. Next, you will learn about variables and mixins and how they will help in building robust CSS code. In addition, you'll learn how to keep your code clean and test it by using style guides. We will then move on to the concept of Bootstrapping and the strength of using Less with Twitter Bootstrap. Going one step further, you will be able to customize Twitter's Bootstrap 3 using Less. Finally, you will learn how to integrate Less into your WordPress themes and explore other web apps that use Less. By leveraging this powerful CSS preprocessor, you will be able to consistently produce amazing web applications while making CSS code development an enjoyable experience.
Table of Contents (15 chapters)
Less Web Development Essentials
About the Author
About the Reviewers

Escaping values

Less is an extension of CSS. This means that Less gives an error when it comes across invalid CSS or evaluates a valid CSS during compilation. Some browsers define properties with an invalid CSS. Well-known examples will include something such as property: ms:somefunction(). Some of these rules can be replaced by vendor-specific rules. It is important to note that invalid property values won't get compiled in Less.

A new function, calc(), in CSS3 is a native CSS way of doing simple math as a replacement for a value of any length.

In both cases, Less won't give us the right value when we compile or import.

@aside-width: 80px;
.content {
width: calc(100% -  @aside-width)

The preceding code gets compiled into the following code:

.content {
  width: calc(20%);

From the preceding code, @aside-width: 80px; is the declaration of a variable with the name aside-width. This variable gets a value of 80 pixels. More information on variables will be covered in the following sections. However...