New Self New Life
No Result
View All Result
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices
New Self New Life
No Result
View All Result
Home Softwares

How to Use the Double Ampersand Selector in Sass [Article]

by admin
2 years ago
in Softwares
How to Use the Double Ampersand Selector in Sass [Article]
Share on FacebookShare on Twitter


The Sass ampersand (&) image is used to reference the mum or dad selector in a nested rule. For instance, the next targets .btn on :hover:

.btn {
  ...
  &:hover {
    background: dodgerblue;
  }
}

We will additionally place the & after a selector to reverse the nesting order:

.btn {
  ...
  .navbar & {
    background: lightsteelblue;
  }
}

This outputs a descendant selector that targets a .btn aspect inside .navbar:

.btn {
  ...
}
.navbar .btn {
  background: lightsteelblue;
}

We will take this idea a step additional with an adjoining sibling combinator.

The Sass Ampersand & the Adjoining Sibling Selector

The adjoining sibling combinator (+) is used to focus on a component’s instant sibling. As an illustration:

.heading + .intro {
  ...
}

This targets any intro class instantly following a component with the category heading. Let’s check out two helpful methods we are able to use this combinator with the & selector.

Adjoining Buttons

Let’s say now we have a button group consisting of a major and a secondary motion button. Each have the category btn.

<div class="btn-group">
  <a category="btn" href="#">Main Motion</a>
  <a category="btn" href="#">Secondary Motion</a>
</div>

The secondary motion button must be a special coloration and have a left margin to separate it from its sibling. We will use the next rule to reference btn, then goal its instant sibling with the identical class:

.btn {
  ...
  & + & {
    margin-left: 15px;
    background: firebrick;
  }
}

If two btn lessons are adjoining siblings, the second will get the firebrick background and left margin. Right here’s the CSS output:

.btn {
  ...
}
.btn + .btn {
  margin-left: 15px;
  background: firebrick;
}

See CodePen Demo

Columns

The adjoining & selector additionally helps with column structure. To create a row the place all however the first column have a left margin (or gutter), we are able to write the next:

.col {
  ...
  & + & {
    margin-left: 30px;
  }
}

The primary column will stay flush with the left facet of the web page, whereas the others get a roomy left margin.

See CodePen Demo

As we simply realized, the “double Sass ampersand” sibling selector is a useful resolution that retains us from writing additional CSS and lessons in our markup. Strategies like these are a number of the some ways Sass helps us write cleaner, extra environment friendly front-end code.

Study Extra Concerning the Sass Ampersand & Different Sass Fundamentals with Treehouse

Treehouse gives a variety of programs and Techdegrees that you should use to enhance your Sass abilities. Study extra about utilizing the Sass ampersand and different Sass fundamentals by signing up for a free trial of Treehouse at the moment!



Source link

Tags: AmpersandArticleDoubleSassSelector
Previous Post

Hackers compromised Okta’s private GitHub repos

Next Post

YouTube Adds New Shorts Insights and Post Presentation Options

Related Posts

How to Add Custom Style Variations to WordPress Blocks — Speckyboy
Softwares

How to Add Custom Style Variations to WordPress Blocks — Speckyboy

by admin
June 2, 2025
Smart software replaces expensive sensors for glass wall detection with 96% accuracy
Softwares

Smart software replaces expensive sensors for glass wall detection with 96% accuracy

by admin
June 1, 2025
User Guide For UnoPim PDF Generator
Softwares

User Guide For UnoPim PDF Generator

by admin
May 31, 2025
Infragistics Ultimate 25.1 includes updates across several of its UI toolkit components
Softwares

Infragistics Ultimate 25.1 includes updates across several of its UI toolkit components

by admin
May 29, 2025
Quick exit from Settings – Vivaldi Android Browser snapshot 3708.4
Softwares

Quick exit from Settings – Vivaldi Android Browser snapshot 3708.4

by admin
June 3, 2025
Next Post
YouTube Adds New Shorts Insights and Post Presentation Options

YouTube Adds New Shorts Insights and Post Presentation Options

Twitter Adds New Qualification Process for Community Notes to Improve Note Value

Twitter Adds New Qualification Process for Community Notes to Improve Note Value

  • Trending
  • Comments
  • Latest
Anant Ambani wedding: Celebs, wealthy elite attend lavish billionaire festivities – National

Anant Ambani wedding: Celebs, wealthy elite attend lavish billionaire festivities – National

March 1, 2024
Product Information Management Trends (PIM)

Product Information Management Trends (PIM)

February 4, 2022
Every Kathryn Hahn Film Performance, Ranked

Every Kathryn Hahn Film Performance, Ranked

December 24, 2022
Deployment Diagrams Explained in Detail, With Examples

Deployment Diagrams Explained in Detail, With Examples

August 11, 2021
How to Build a JavaScript Search [Article]

How to Build a JavaScript Search [Article]

August 30, 2022
6 Key Elements of Competitor Analysis That Will Help Your Business Win Out

6 Key Elements of Competitor Analysis That Will Help Your Business Win Out

May 13, 2021
15 Best Movies Like Parasite

15 Best Movies Like Parasite

February 20, 2022
How to Build a DIY Spotify Music Player with Raspberry Pi Pico

How to Build a DIY Spotify Music Player with Raspberry Pi Pico

May 13, 2025
Major Labels Shift Gears, Explore Licensing Deals With Controversial AI Platforms Suno and Udio

Major Labels Shift Gears, Explore Licensing Deals With Controversial AI Platforms Suno and Udio

June 3, 2025
Samsung Galaxy Z Fold 7 Rumored Features and Design Updates

Samsung Galaxy Z Fold 7 Rumored Features and Design Updates

June 3, 2025
Ellen Pompeo Detained By TSA, Bomb Squad Called In

Ellen Pompeo Detained By TSA, Bomb Squad Called In

June 3, 2025
X Rolls Out Support for 4K Video Uploads

X Continues To Highlight Misleading Claims About Its Popularity

June 3, 2025
May 30-June 1 Box Office Recap – ‘Lilo & Stitch’ crosses $600M worldwide, while ‘Mission: Impossible – The Final Reckoning’ crosses $350M worldwide. ‘Karate Kid: Legends’ and ‘Bring Her Back’ have solid debuts, while ‘The Phoenician Scheme’ opens with the best per-theater average ($93K) of the year.

May 30-June 1 Box Office Recap – ‘Lilo & Stitch’ crosses $600M worldwide, while ‘Mission: Impossible – The Final Reckoning’ crosses $350M worldwide. ‘Karate Kid: Legends’ and ‘Bring Her Back’ have solid debuts, while ‘The Phoenician Scheme’ opens with the best per-theater average ($93K) of the year.

June 3, 2025
Jonathan Joss, ‘King of the Hill’ actor, killed in Texas shooting – National

Jonathan Joss, ‘King of the Hill’ actor, killed in Texas shooting – National

June 3, 2025
What Is the Best Brand of Workout Clothes? (2025 Guide)

What Is the Best Brand of Workout Clothes? (2025 Guide)

June 3, 2025
Samsung may incorporate Perplexity’s AI tech in its phones

Samsung may incorporate Perplexity’s AI tech in its phones

June 2, 2025
New Self New Life

Your source for entertainment news, celebrities, celebrity news, and Music, Cinema, Digital Lifestyle and Social Media and More !

Categories

  • Celebrity
  • Cinema
  • Devices
  • Digital Lifestyle
  • Entertainment
  • Music
  • Social Media
  • Softwares
  • Uncategorized

Recent Posts

  • Major Labels Shift Gears, Explore Licensing Deals With Controversial AI Platforms Suno and Udio
  • Samsung Galaxy Z Fold 7 Rumored Features and Design Updates
  • Ellen Pompeo Detained By TSA, Bomb Squad Called In
  • Home
  • Disclaimer
  • DMCA
  • Privacy Policy
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2021 New Self New Life.
New Self New Life is not responsible for the content of external sites. slotsfree  creator solana token

No Result
View All Result
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices

Copyright © 2021 New Self New Life.
New Self New Life is not responsible for the content of external sites.

casino filipino