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

Extending components using :extend


You can read more about the Less :extend pseudo class from the Using extend to merge selectors recipe of Chapter 5, Extending and Referencing. In this recipe, you will see how to use this pseudo class to make all the images in your Bootstrap project responsive by default.

Getting ready

Download the source version of Bootstrap from http://getbootstrap.com/getting-started/#download.

How to do it...

In Twitter's Bootstrap version 2, images (the img tag) were responsive by default. In Bootstrap version 3, an image can only be made responsive by adding the .img-responsive parameter to the img tag. You can use the following steps to make your images responsive by default again:

  1. Install the source version of Bootstrap as described in the Downloading and installing Bootstrap recipe of this chapter.

  2. Open the less/bootstrap.less file and add the following Less code at the end of this file:

    img {
      &:extend(.img-responsive);
    }
  3. Recompile Bootstrap by running the following...