I have a Vuetify application that customers can embed on their websites.
Problem A:
What can happen sometimes is that our Vue app conflicts with the CSS of the customers web page. Generic class names like row
, col
, or container
mess up their design.
Solution A:
We can solve this by prefixing our generic class names with the parent element which is unique. We can run some regex on our css file to prefix everything. So .row{}
becomes #unique-parent-div .row {}
which solves the problem on our side.
Problem B:
But what if the problem is the other way around and the host webpage conflicts with our Vue app? We can't make changes to our customers web page. We could ask them but it would very annoying to our customers.
We can't really change our class names either because this is what happens in vuetify:
<v-layout row wrap>
<v-col cols="12" class="pa-0">
Vuetify automatically turns these into HTML with generic class names like row
, col
and layout
, which gets the customers CSS into our application, breaking the design.
Is there any way to solve this? Perhaps changing the default class names in vue, or somehow block the host CSS?
What I have tried
I tried setting this (and several variations) in my root element without any success:
#root-element,
#root-element::before,
#root-element::after,
#root-element *
#root-element *::before,
#root-element *::after {
all: initial;
}