How to scope internal Vue application css from rest of the website?
Ok, I've figured it out.
Pretty simple really, combined with this answer to prevent parent -> child inheritance. I scoped all Vue css into #app { /*styles*/ }
INCLUDING the bootstrap import. E.g.
<style type="text/scss" lang="scss">
#app {
@import '../node_modules/bootstrap/scss/bootstrap';
// rest of vue global styles go here.
// child components may use scoped
}
</style>
Note: I am NOT using scoped
attribute on the root vue component.
Override CSS for specific Bootstrapvue Components
This works:
<style lang="scss">
.btn-group-toggle:not(#_) label {
/* general styles */
&.disabled {
}
&.focus {
}
&.active {
}
&:hover {
}
}
</style>
When adding scoped
attribute to the <style>
tag, you're largely at the hand of your installed pre-processor which might or might not be able to parse >>>
, /deep/
, ::v-deep
or :deep()
, depending on version.
To stay away from such issues, I use the suggestion made in Vue Loader's docs: I create a separate <style>
tag for bootstrap-vue internals, without the scoped
attribute and keep the rest of component style rules in a <style scoped>
.
Working demo.
Related Topics
How to Customize the HTML5 Input Range Type Looks Using CSS
Tint Image Using CSS Without Overlay
Getting Columns to Wrap in CSS Grid
Select Specific Element Before Other Element
Sass/Compass - Convert Hex, Rgb, or Named Color to Rgba
CSS Multi-Column Layout of List Items Doesn't Align Properly in Chrome
How to Start a New Column in Flex Column Wrap Layout
How to Rotate Text Left 90 Degree and Cell Size Is Adjusted According to Text in HTML
Align Button at the Bottom of Div Using CSS
Keep Background Image Fixed During Scroll Using CSS
Use Custom Fonts with Wkhtmltopdf
Is a <Button> Allowed to Have Display:Grid
Export CSS Changes from Inspector (Webkit, Firebug, etc)
How to Get a React Component's Size (Height/Width) Before Render