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

Building a semantic grid with mixins


In the Building a grid with grid classes recipe of this chapter, you can read how to build a grid with CSS grid classes. Using these grid classes on the div elements breaks the semantic nature of HTML5. In this recipe, you will learn how to keep the HTML5 semantic tags intact when deploying a grid.

Getting ready

In this recipe, you will have to use the code from the Building a grid with grid classes and Creating responsive grids recipes of this chapter. You will use the command-line lessc compiler.

How to do it...

You need to perform the following steps:

  1. Leveraging the Less code from the Building a grid with grid classes and Creating responsive grids recipes, you can create a file called grid.less that will contain the following Less code:

    @grid-columns: 4;
    @basefontsize: 16px;
    @sm-breakpoint: unit((768px / @basefontsize), em);
    
    .set-span(@col-number) {
      flex-basis: ((100% / @grid-columns) * @col-number);
      max-width: ((100% / @grid-columns) * @col-number...