Removing an element added by ::before pseudo selector

前端 未结 3 813
谎友^
谎友^ 2021-01-13 20:14

I have the following case: (styling is done in SASS and unnecessary stylings are omitted.)

.header {
  ...
  &::before {
    ...
    position: absolute;         


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-01-13 20:58

    If you are manipulating the DOM by using JavaScript, you can add a class name - for instance .remove-bar - to the element having .header in order to remove the pseudo-element (generated content):

    .remove-bar {
        &::before { content: none; }
    }
    

    Also make sure that it is placed after the previous styles, or use a more specific selector if needed.

提交回复
热议问题