Reset/remove CSS styles for element only

前端 未结 14 1037
长情又很酷
长情又很酷 2020-11-22 00:52

I\'m sure this must have been mentioned/asked before but have been searching for an age with no luck, my terminology must be wrong!

I vaguely remember a twee

14条回答
  •  我在风中等你
    2020-11-22 01:11

    If you happen to be using sass in a build system, one way to do this that will work in all the major browsers is to wrap all your style imports with a :not() selector like so...

    :not(.disable-all-styles) {
      @import 'my-sass-file';
      @import 'my-other-sass-file';
    }
    

    Then you can use the disable class on a container and the sub-content won't have any of your styles.

    Nothing in this div is affected by my sass styles.

    Of course all your styles will now be prepended with the :not() selector, so it's a little fugly, but works well.

提交回复
热议问题