Can a css value be ignored ?
I have two divs :
<div id="div1" class="class1 class2">
</div>
<div id="div2" class="class1">
</div>
Can the css class be applied to just divs which are styled with class1 and if they contain class2 then its ignored ? So in above divs just div2 is styled with class1 because div1 is also styled with class2.
To override the CSS properties of a class using another class, we can use the ! important directive. In CSS, ! important means “this is important”, and the property:value pair that has this directive is always applied even if the other element has higher specificity.
Sometimes you want to disable a part of the CSS code without deleting it. To do so you can put "/*" and "*/" around the code you want to disable.
In CSS, to exclude a particular class, we can use the pseudo-class :not selector also known as negation pseudo-class or not selector. This selector is used to set the style to every element that is not the specified by given selector. Since it is used to prevent a specific items from list of selected items.
You can use the :not
selector. Here's an example:
CSS
.red:not(.yellow) {
color: red;
}
.yellow {
background-color: yellow;
}
HTML:
<div class = "red yellow">
Glee's awesome!
</div>
<div class = "red">
Glee's awesome!
</div>
Demo.
I hope that helped!
Write like this:
.class1{
background:red;
}
.class1.class2{
background:none;
}
You can use :not
selector:
$('.class1:not(.class2)')
YESSSS,
use !important after the css property
for example height:30px !important
if your class1 have height:30px
and class2 height:40px
then user !important in class2 height
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With