A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://vue-loader.vuejs.org/en/features/scoped-css.html below:

Website Navigation


Scoped CSS | Vue Loader

# Scoped CSS

When a <style> tag has the scoped attribute, its CSS will apply to elements of the current component only. This is similar to the style encapsulation found in Shadow DOM. It comes with some caveats, but doesn't require any polyfills. It is achieved by using PostCSS to transform the following:

Into the following:

# Mixing Local and Global Styles

You can include both scoped and non-scoped styles in the same component:

# Child Component Root Elements

With scoped, the parent component's styles will not leak into child components. However, a child component's root node will be affected by both the parent's scoped CSS and the child's scoped CSS. This is by design so that the parent can style the child root element for layout purposes.

# Deep Selectors

If you want a selector in scoped styles to be "deep", i.e. affecting child components, you can use the >>> combinator:

The above will be compiled into:

Some pre-processors, such as Sass, may not be able to parse >>> properly. In those cases you can use the /deep/ or ::v-deep combinator instead - both are aliases for >>> and work exactly the same. Based on the example above these two expressions will be compiled to the same output:

# Dynamically Generated Content

DOM content created with v-html are not affected by scoped styles, but you can still style them using deep selectors.

# Also Keep in Mind

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4