Q
Q
quiplunar2020-06-02 18:05:05
Sass
quiplunar, 2020-06-02 18:05:05

scss how to remove selector?

selector-replace('.a .b .c .d', '.a', '');

This design doesn't work. How can I remove the selector by name?

There is such a function for deleting by index:

@function remove-selector($sel) {
    @return '';
}

@function selector-nth($sel, $n, $f, $args...) {
    $collector: ();
    @each $s in $sel {
        $modified: call($f, nth($s, $n), $args...);
        $collector: append($collector, set-nth($s, $n, $modified), comma);
    }

    @return $collector;
}

selector-nth('.a .b .c .d', -2, remove-selector)


How can I change it to search by name?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question