Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Less Web Development Essentials (Second Edition)
  • Table Of Contents Toc
Less Web Development Essentials (Second Edition)

Less Web Development Essentials (Second Edition)

By : Bass Jobsen
1 (1)
close
close
Less Web Development Essentials (Second Edition)

Less Web Development Essentials (Second Edition)

1 (1)
By: Bass Jobsen

Overview of this book

If you use CSS for web development tasks and want to learn how to create maintainable and reusable code, this is the book for you. Basic knowledge of web development would be helpful.
Table of Contents (9 chapters)
close
close
6
6. Using the Bootstrap 3 Frontend Framework
8
Index

Referencing the parent selector with the & symbol


The & symbol plays a special and important role in Less as it references the parent of the current selector. You can use it to reverse the order of nesting, and to extend or merge classes. You will see that the following example will tell you more than what can be expressed in a thousand words:

.class1
{
  .class2{
    property: 5;
  }
}

.class1
{
  .class2 & {
    property: 5;
  }
}

This code will compile into the following code:

.class1 .class2 {
  property: 5;
}
.class2 .class1 {
  property: 5;
}

You can see that .class2 becomes the parent of .class1 when you use the & symbol after it. The & symbol can also be used to reference nesting that is outside the mixin, as can be seen in the example about the conditional .ie8 class in the Passing rulesets to mixins section.

The & symbol can also be used to nest and append pseudo classes to a class. Later on, you will see that you can use it to append classes too. A simple example...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Less Web Development Essentials (Second Edition)
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon