Home > Web Front-end > CSS Tutorial > How to Style Child Components in Vue.js Using CSS Selectors?

How to Style Child Components in Vue.js Using CSS Selectors?

Mary-Kate Olsen
Release: 2024-12-28 06:18:18
Original
206 people have browsed it

How to Style Child Components in Vue.js Using CSS Selectors?

Styling Child Components in Vue.js with /deep/, >>>, or ::v-deep

In the context of Vue.js, granular styling of child components can be achieved using specific CSS selectors. However, issues may arise during implementation.

Vue 2.0 - 2.6

To penetrate child components and select nested elements, you can employ either ::v-deep (with Sass) or >>> (without Sass) in your CSS rules, as follows:

Sass:

::v-deep .child-class {
    background-color: #000;
}
Copy after login

Other CSS:

>>> .child-class {
    background-color: #000;
}
Copy after login

Note that the