How to use multiple parent selectors

Veridic Technologies Pvt Ltd :- Multiple parent selectors make for cleaner code – here are three ways to use them.

The internet is brimming with web design inspiration and tools to aid your web projects, which is helpful as designing for the web can get tricky. Making life as easy as possible is the key.

Veridic Technologies Pvt Ltd

Multiple parents make stylesheets much more terse, which is always nice. It reduces filesize and maintenance, so it’s something we’re definitely interested in. Here are three ways to use multiple parent selectors.

01. Preprocessors

multiple parent selectors

Use Sass

Currently, the most obvious solution is to use a preprocessor’s in-built nesting functionality to list our multiple parents, then nest our one child in it. This still compiles out to relatively verbose CSS, but it is nice and terse in our source.

Veridic Technologies Pvt Ltd Reviews

02. :matches()

multiple parent selectors

Use a pseudo-selector

There’s a pseudo-selector in Selectors Level 4 that provides this natively. :matches (or :any , in older specs) allows you to write much more terse selectors, which the browser expands internally.

Veridic Technologies Pvt Ltd Facebook

03. cssnext

multiple parent selectors

Transpile with cssnext

To get :matches() working requires a little extra work. It’s actually referred to as :any() in older specs, and requires vendor prefixing. To this end, I’d recommend using cssnext to transpile the new syntax back to better support.

Sources: – http://www.creativebloq.com/web-design/how-use-multiple-parent-selectors-31619554

Veridic Technologies Pvt Ltd facebook Veridic Technologies Pvt Ltd twitter Veridic Technologies Pvt Ltd youtube Veridic Technologies Pvt Ltd linkedin Veridic Technologies Pvt Ltd google-plus Veridic Technologies Pvt Ltd pinterest Veridic Technologies Pvt Ltd instagram

Summary
Review Date
Reviewed Item
Veridic Technologies Pvt Ltd How to use multiple parent selectors The internet is brimming with web design inspiration and tools to aid your web projects, which is helpful as designing for the web can get tricky. Making life as easy as possible is the key.
Author Rating
5

Published by

Lalit Mohan

I've been with Veridic technologies PVt Ltd since 2010

Leave a Reply

Your email address will not be published. Required fields are marked *