Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is :not(style) ~ :not(style) in CSS?

Mui automatically added a :not(style) ~ :not(style) which I needed an !important to override in my sx.

.css-1rb8ayf-MuiStack-root > :not(style) ~ :not(style) {
  margin-top: 40px;
}
.css-d13d9m-MuiStack-root {

  display: flex;
  flex-direction: column;
  margin-top: 0 !important;
}

What is this :not(style) ~ :not(style) ?

Thanks very much !

like image 250
EBDS Avatar asked Oct 31 '25 23:10

EBDS


1 Answers

This selector will apply it's styles to all elements that are not a style in the .css-1rb8ayf-MuiStack-root element and and are preceded by another element that is not a style element:

.css-1rb8ayf-MuiStack-root > :not(style) ~ :not(style) {
    color: red;
}
<div class="css-1rb8ayf-MuiStack-root">
    <style></style>
    <style></style>
    <p>Will not be targeted</p>
    <p>Will be targeted</p>
</div>

If you don't want to use !important, you could also use the same selector again:

.css-1rb8ayf-MuiStack-root,
.css-1rb8ayf-MuiStack-root > :not(style) ~ :not(style) {
    margin-top: 0;
}
like image 133
Douwe de Haan Avatar answered Nov 03 '25 13:11

Douwe de Haan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!