Vuetify - Use SCSS to change or prepend to class names - css

I've created a web component using Vue2 & Vuetify2 and it's working almost flawlessly bar a few websites where there are CSS clashes.
The problem is that the web component is not in a shadowDOM and as much as I've tried getting this to work, it just doesn't (seems the issue lies with Vuetify + shadowDOM).
As an alternative, would it be possible to change or prepend to class names to stop CSS conflicts?
For example row is a typically used class name. Would it be possible to prepend either widget, .widget or #widget to all other classes & id's?
Demo of the widget.

Related

How to tell tailwind that I want different behaviours to different elements by just adding a single class

I've actually coded the whole app in plain HTML, CSS and JS and now I'm converting it in Tailwind css.
Problem -> There is a class named active which gets attached to different HTML element when I press Enter. And I've defined different behaviours for different elements whenever that class sticks to those elements. But in tailwind I do not know how to do this thing. Somehow I managed to do this with error class but do not know about active Active Class in HTML,CSS and JS. Active Class in HTML, CSS and JS. I want to copy the behaviour of active classes in Tailwind css

The same class name in two different css files conflict in ReactJS

I have a component folder and two different components in it, every component has its own css file with the link in its jsx file.
:
when I use a the same class name in them it affects the other component too! While the other component has its own css file and link.
Why is that?
For example:
In both components I have a class named: "PlayerPhoto"
when I change its height and width, the photo in other components (with separate css file but the same class name) would change too!
It happens because your css is imported simply as normal css - without unique identificator. You need to specify classes with unique names or have a look at Css Modules which solve this problem and creating unique classes automatically
Or you can use libraries as EmotionJS or styled-components
Your app.js file may has the property for the className="PlayerPhoto", make sure that your app.css has not the same className if there were, then it overwrite your component base css.
You can also use inline css, to overcome this type of issues.

Same style class for different components in Angular 6

I have css class which needs to be added to three different component(for example) which might not require for other components of our application.
which one would be the best approach.
add that css class to style.css (global css)and use it or
add it to three different component specific style sheet as it is not used anywhere in the application(is this considered as code duplicate ?)
Thanks!
I would say that adding it to the global styles is just fine for this purpose. View encapsulation is cool, but the cascading part of CSS is still something that we're supposed to take advantage of...just as long as you're still cognizant of keeping styles organized and not too high of specificity.
Conversely, if you knew all three components would share parent component, you could turn off view encapsulation for that component and add the class there, which is essentially the same as adding to global styles with the difference being the style would only be loaded when the component is loaded.
You could also use ::ng-deepon a parent component to target its children. Sass brings other solutions, but it doesn't look like you're using .scss files.

Different Styling Classes for airbnb/react-dates

I'm currently having the problem that I leverage the Airbnb dates in two different locations within my React project. The dates are styled differently. Therefore, I created 2 separate CSS files that overwrite the default styling.
Even though, there are 2 different CSS files in 2 different locations the latest changes overwrite the initial styling changes. So for some reason, both datepickers share the same styling.
I want to mention that I use style-loaders.
Any ideas?
2020:
For anyone who comes across this now and also has this issue, you may have tried to use CSS modules since that would eliminate the “global CSS” problem.
However, I tried that and it doesn’t load CSS module files so that won’t work at all.
However, I was able to solve it by using styled-components. Each datepicker had it own component and I used styled-components to write a base container and then, ALL the override styles for each datepicker goes into that styled component.
Boom, that solves the problem of the CSS styling clashing globally.

apply external CSS to specific area

I'd like to import an external CSS (eg. Bootstrap) into my site-- the problem is I'd like to apply the Bootstrap styles only to a specific region of the page. When I include Bootstrap, it applies its styles to the entire page, restyling all tables, divs, etc.
Is it possible to only apply Bootstrap to a region (say a parent div or something?)
Thanks
The only way to do this is to have a separate iframe for the content you want to style with Bootstrap (unless you want to edit the Bootstrap CSS, and add your outer div's selector to the beginning of EVERY rule).
HTML5 introduced the new scoped attribute, which is made specifically for your use case, but has not yet been implemented by any one of the major browsers.
If you are using jQuery (which you probably are, since all of Bootstrap's Javascript functionality is dependent upon jQuery), you might wanna try Simon Madine's jQuery Scoped CSS plugin.
Import Bootstrap before your own styles. That way your own styles will overwrite the changes made by Bootstrap where applicable.
I've only tried this locally and not given it any thorough testing but it seems to work fine. I created a div around the content and assigned it an id. Then prefixed all of the bootstrap selectors with the id I assigned the surrounding div. The prefixing was done with a couple of search and replace operations. Perhaps it can be done easier with less
Forgot to mention that the body selector of the bootstrap.css has to be replaced with the id and not prefixed like the other selectors.

Resources