Reputation: 47
I have html something like this:
.wrapper_1 {
color: red;
}
.container *:not(.wrapper_1) {
color: blue;
}
.wrapper_2 {
color: green;
}
<div class="container">
<div>
<div>
<div>
<span>This is the test content 1 .</span>
</div>
<div class="wrapper_1">
This is the test content 2
<br>
<span>This is the test content 3</span>
</div>
<span class="wrapper_2">This is the test content 4.</span>
</div>
</div>
</div>
I have to apply or replace container CSS for all the children except the div
having class wrapper_1
(all the nested children). As I know I can do something like this: .container *:not(.wrapper_1)
but it's not ignoring all the children inside .wrapper
class, Is there any other workaround?
Upvotes: 0
Views: 60
Reputation: 789
you can learn here how to use :not
CSS
selector here :not css trick
.wrapper_1 {
color: red;
}
.container *:not(.wrapper_1,.wrapper_1 > *){
color: blue;
}
.wrapper_2 {
color: green;
}
<div class="container">
<div>
<div>
<div>
<span>This is the test content 1 .<span>
</div>
<div class="wrapper_1">
This is the test content 2
<br>
<span>This is the test content 3</span>
</div>
<span class="wrapper_2">This is the test content 4.</span>
</div>
</div>
</div>
Upvotes: 1
Reputation:
Try with this style:
<style>
.wrapper_1 {
color: red;
}
.container *:not(.wrapper_1.*) {
color: blue;
}
.wrapper_2{
color: green;
}
</style>
Upvotes: 0