I'm using the v-deep selector to style tiptap, a rich text editor. For that the .ProseMirror class has to be accessed like so (SCSS):
editor-content {
// ... styles
&::v-deep(.ProseMirror) {
// ... styles
}
}
But how do I style the .ProseMirror class with TailwindCSS? I can't add classes to it, at least I don't know how. Is it possible?
Tailwind can be used like regular CSS.
Try that one
editor-content {
&::v-deep(.ProseMirror) {
#apply bg-red-500;
}
}
This question already has answers here:
Modifying the middle of a selector in Sass (adding/removing classes, etc.)
(2 answers)
Closed 7 years ago.
I know you can add a parent selector like this:
.main-selector {
.parent-selector & {
}
}
I'm trying to figure out if there is a way to go back to the .main-selector so I can add a hover state style to a child element. So, something like this:
.main-selector {
.child-selector {
*styles*
.main-selector:hover & {
*hover styles*
}
}
}
The correct syntax would be:
.main-selector {
.child-selector {
*styles*
}
&:hover {
*hover styles*
}
}
This will produce a hover for your main-selector. You could do it the other way arround, like so:
.main-selector {
&:hover {
*hover styles*
}
.child-selector {
*styles*
}
}
This question already has answers here:
CSS Selector that applies to elements with two classes
(2 answers)
Closed 7 years ago.
I have a <div> in my application. It is set to have a class of "enumPanel" and dynamically I add the class "current".
How can I wire this up in less so that my properties will come into effect only when both classes are present on the div ?
.enumPanel .current {
// this does not seem to work
}
CSS
.enumPanel.current {}
LESS
.enumPanel {
&.current {
}
}
.enumPanel.current {
// this will work
}
This question already has answers here:
Can a CSS class inherit one or more other classes?
(29 answers)
Closed 7 years ago.
There is a way to do this in css ?
.main-div {
.input { ... }
.select { ... }
.a { ... }
.li { ... }
....
}
You would need a preprocessor language like Sass or LESS. Then you could do exactly that.
You could use a CSS-preprocessor like LESS or SASS. But there is currently no way to accomplish this in pure CSS.
I have a very wierd question, I dont know wether if its possible in css or not
Suppose I have say 3 different css classes as shown below, as you can see I have a common property of all these classes, I want to declare this color somewhere else and pass a reference to it here, so if next time I want to change the color I can simply change at one place rather than changing in all the 5 classes.
I know that you can use body{}, or a wrapper for this but that would affect the colors of the entire site right ? Is there a way to do this ?
Is this even possible ?
.abc {
color:red;
}
.abc2 {
color:red;
}
.abc3 {
color:red;
}
.abc4 {
color:red;
}
.abc5 {
color:red;
}
The bad news: you can't do it in CSS.
The good news: you can write in a meta-CSS language like LESS, which then processes a LESS file to pure CSS. This is called a "mixin".
In LESS:
#errorColor: red;
.error-color {
color: #errorColor;
}
#error-1 {
.error-color;
}
.all-errors {
.error-color;
}
More info: http://lesscss.org/#-mixins
if you want to declare all of them at a time, you can use:
.abc, .abc2, .abc3, .abc4, .abc5 {
color:red;
}
Or you can declare an additional class & add to all the .abc, .abc2.... & make its color:red;.
This can not be done with CSS, but that is still a very popular thing to do by using a CSS preprocessor such as LESS, SASS, SCSS, or Stylus.
A preprocessor will let you define a variable (say $red = #F00). It will replace the variable in your CSS document with the variable value for you, allowing you to write very DRY and module CSS.
This functionality is referred to as "CSS variables", which is part of the future spec, but not yet implemented on any browsers.
For now, the best way to do this in pure CSS is to declare an additional class for the desired "global", and then add that class to all relevant items.
.abc_global { color: red; }
.abc1 { /* additional styling */ }
.abc2 { /* additional styling */ }
<div class="abc1 abc_global"></div>
<div class="abc2 abc_global"></div>
With LESS
You are able to define that red color once:
.myRedColor {
color:red;
}
Now you can call that red on any CSS styles. Even NESTED styles! It's a wicked tool!
.abc1 {
.myRedColor;
}
.abc2 {
.myRedColor;
}
.abc3 {
.myRedColor;
}
.abc4 {
.myRedColor;
}
NESTED EXAMPLE:
.abc {
.itsEasyAsOneTwoThree{
.myRedColor;
}
}
Now all of our "itsEasyAsOneTwoThree" classes that are properly nested inside of an "abc" class will be assigned the red style. No more remembering those long #867530 color codes :) How cool is that?!
You can also use PostCSS with the plugin postcss-preset-env and support custom properties/variables, then use the :root selector to add global css variables.
:root {
--color-gray: #333333;
--color-white: #ffffff;
--color-black: #000000;
}