CSS reset that sets everything to default values

前端 未结 6 1759
忘了有多久
忘了有多久 2020-12-03 23:08

I\'m working on a browser extension that adds it\'s UI to the pages DOM. On some pages I have the problem certain styles affect my UI. To counter this I keep my UI underneat

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 23:56

    I have come across the same problem. The usual CSS normalizers listed by the other answers does not answer the question because it is made to cancel the differences across the browser's default styles.

    In the context of an extension, I needed to cancel every specific style that may exist on a random website.

    I have come across this solution (I am not sure if it was possible at the time of the question, 7 years ago).

    .your-container-class,
    .your-container-class *,
    .your-container-class *::before,
    .your-container-class *::after {
        all: initial;
    }
    

    So far it seems to achieve the goal by removing the differences across websites. The downside is that it resets even some default styles (ol, ul, li not behaving like lists for example).

提交回复
热议问题