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

Using parametric mixins


Mixins can be used with parameters, which make them more flexible and reusable.

Getting ready

For this recipe, you will have to create the following file and folder structure:

You can edit these files with your favorite text editor and inspect the results with your web browser.

How to do it…

In this recipe, you will leverage a simple mixin to set the border radius of the HTML elements by performing the following steps:

  1. You first need to create a valid HTML5 document named index.html with the following elements:

    <header>the header</header>
    <p>this is a paragraph</p>
    <footer>the footer</footer>

    Make sure the head section of your index.html file also contains the following code:

    <link rel="stylesheet/less" type="text/css" href="project.less">
    <script src="less.js" type="text/javascript"></script>
  2. Open the project.less file with your text editor and write the following mixins into it:

    .rounded-corners(@radius) {
      border-radius...