HomeLinuxHow one can Goal a CSS Class Inside One other CSS Class

How one can Goal a CSS Class Inside One other CSS Class


Lessons play a vital function when discussing the specification of any ingredient in CSS or some other programming language. To precise just a few kinds and results on the HTML elements, lessons are generated in CSS. By giving the property values, the entire CSS properties may be added to the category physique.

This put up will state about focusing on a CSS class inside one other CSS class.

How one can Goal CSS Class Inside One other CSS Class?

To focus on a CSS class inside one other CSS class, first, make div containers and add class attributes in every container. Then, entry a number of lessons in CSS by using their title/worth.

Step 1: Add a “div” Container

Initially, add a div ingredient with the assistance of “<div>”. Then, allocate a category attribute for additional use.

Step 2: Make Nested “div” Containers

Subsequent, make nested div containers by following the identical process of step 1:

Output

Step 3: Apply Styling on Foremost “div” Container

Entry the primary “div” container with the assistance of sophistication title as “.main-content”:

.main-content {

width: 40%;

margin: 0 auto;

colour: blue;

border: 2px dotted blue;

text-align: heart;

}

Right here:

  • width” specifies the ingredient’s width dimension.
  • margin” allocates area across the ingredient outdoors the outlined border.
  • colour” defines the colour for the added textual content within the ingredient.
  • border” defines a top level view or boundary across the ingredient in HTML.
  • Textual content-align” defines the alignment of the ingredient’s textual content.

Step 4: Model one other class

Entry the CSS important class and different nested lessons by utilizing their names. Then, set the width of the container by specifying the worth in keeping with your selection:

.main-content .desk {

width: 80%;

}

Moreover, entry the opposite class by following the identical process as above and apply the CSS properties talked about within the beneath code snippet:

.main-content .c-right {

show: inline-block;

font-size: 20px;

}

In keeping with the above code snippet:

  • show” property is used for setting the show of a component.
  • font-size” specifies the dimensions of the textual content added within the container.

Now, entry the opposite lessons by using the identical technique and apply the next CSS properties as talked about beneath:

.main-content .c-left {

width: 140px;

margin-right: 6px;

font-size: 16px;

}

To take action, we are going to apply “width”, “margin-right” and “font-size” for styling functions.

Furthermore, entry the primary “div” container alongside different nested div container by using their class title and apply the next CSS properties

.important .c-right {

width: auto;

font-size: 15px;

colour: #fff;

margin-right: 20px;

font-weight: regular;

}

Output

That’s all about focusing on a CSS class inside one other CSS class.

Conclusion

To focus on a CSS class inside one other CSS class, first, entry the primary “div” via the assigned class attribute. Then, entry one other “div” container by following the identical process. Moreover, customers can goal a CSS class inside different CSS class. This put up has demonstrated the tactic for focusing on a CSS class inside one other CSS class.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments