Change visibility of a control in SCSS from nested class

Forums AngularChange visibility of a control in SCSS from nested class

Answers (1)

Add Answer
Umang Ramani Marked As Accepted
Staff answered 2 years ago

In order to change the visibility of a control in SCSS from a nested class, you can use the & selector to target the parent element. For example, if you have an HTML structure like this:

<div class="parent">
  <div class="child"></div>
</div>

And you want to hide the child element from within a nested class, you can do the following in SCSS:

.parent {
  .nested-class {
    // Hide the child element
    & .child {
      display: none;
    }
  }
}

 

In the above example, the & selector refers to the parent element with the class “parent”. The “.nested-class” selector targets the element with the class “child” within the parent element. The “display: none” property is used to hide the child element.

You can also use other CSS properties like “visibility: hidden” or “opacity: 0” to hide the element, depending on your needs.

Subscribe

Select Categories