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

Creating bidirectional styling without code duplication


Some languages, including Arabic, Farsi, Hebrew, and Urdu, are written from right-to-left (rtl). In this recipe, you will learn how to write Less code that can be compiled for rtl and ltr languages by leveraging the Less-bidi mixin library.

Getting ready

For this recipe, you will have to download the Less-bidi mixin library from https://github.com/danielkatz/less-bidi. The Less code will be compiled in the browser by using the client-side less.js compiler, as described in the Downloading, installing, and integrating less.js recipe in Chapter 1, Getting to Grips with the Basics of Less.

How to do it…

In this recipe, you will create the Less and HTML code for the example shown at https://github.com/danielkatz/less-bidi, as follows:

  1. Download and unzip the Less-bidi mixin library into your working directory.

  2. Then, create a bidi.less file that contains the following Less code:

    @import "less-bidi-master/src/bidi.less";
    
    .ltr {
      .style(ltr);
    }
    ...