Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a triple greater than selector in css?

I saw the following CSS code with what appears to be a triple greater than selector.

.b-table >>> .table-wrapper {
  overflow-x: auto; 
}

I know it's referencing a Buefy table component and applying a specific style to elements that have a table-wrapper class, but what does the >>>operator mean exactly? Based off this answer I'm thinking it might be for applying styles to children of children of children, is that accurate? If so, why doesn't it seem to work with other amounts of >?

like image 503
Dan Mandel Avatar asked Apr 22 '19 21:04

Dan Mandel


People also ask

What is greater than selector in CSS?

The greater than sign (>) selector in CSS is used to select the element with a specific parent. It is called as element > element selector. It is also known as the child combinator selector which means that it selects only those elements which are direct children of a parent.

What are the 3 types of selectors in CSS?

Simple selectors (select elements based on name, id, class) Combinator selectors (select elements based on a specific relationship between them) Pseudo-class selectors (select elements based on a certain state)

How do I style all 3 elements in CSS?

Yes, you can use what's known as :nth-child selectors. In this case you would use: li:nth-child(3n) { // Styling for every third element here. }


2 Answers

>>> operator is Vue.js specific feature and called deep selector. In scoped CSS, you cannot apply CSS to child components without deep selector.

As your example, these two selector won't be applied.

<style scoped>
.table-wrapper {
  overflow-x: auto !important;  /* won't work */
}
.b-table .table-wrapper {
  overflow-x: auto !important;   /* won't work */
}
</style>

It needs deep selector.

<style scoped>
.b-table >>> .table-wrapper {
  overflow-x: auto; 
}
</style>
like image 73
noobar Avatar answered Oct 31 '22 14:10

noobar


It is shadow-piercing descendant combinator. In Angular, >>>, /deep/ and ::ng-deep are the same (source: https://angular.io/guide/component-styles#deprecated-deep--and-ng-deep). It is deprecated and support has ben removed from major browsers. For example, it has been removed since Chrome version 63, around December 5 2017 (source: https://www.chromestatus.com/feature/6750456638341120)

like image 1
Lee Chee Kiam Avatar answered Oct 31 '22 14:10

Lee Chee Kiam