Last active
March 10, 2023 20:10
-
-
Save otakupahp/2d73693ddfbe67cd848c50e09d7c198a to your computer and use it in GitHub Desktop.
Add a new class on an specific position
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Desired output | |
// .woocommerce-page.single-product main .product_cat-intentional-pause form.cart #wc-stripe-payment-request-wrapper | |
.woocommerce-page.single-product { | |
main { | |
form.cart { | |
#wc-stripe-payment-request-wrapper { | |
$selector: nth(&,1); // Current element | |
$grandparent: nth($selector, -2); // Grandparent selector | |
$grandparent-pos: index($selector, $grandparent); | |
$new-grandparent: set-nth($selector, $grandparent-pos, '.extra-class form.cart'); | |
@at-root #{$new-grandparent} { | |
color: red; | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.woocommerce-page.single-product main .product_cat-intentional-pause form.cart #wc-stripe-payment-request-wrapper { | |
color: red; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"sass": { | |
"compiler": "dart-sass/1.32.12", | |
"extensions": {}, | |
"syntax": "SCSS", | |
"outputStyle": "expanded" | |
}, | |
"autoprefixer": false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment