How to ignore parent css style

前端 未结 10 1309
逝去的感伤
逝去的感伤 2020-12-23 18:58

I\'m wondering how to ignore a parent style and use the default style (none). I\'ll show my specific case as an example but I\'m pretty sure this is a general question.

10条回答
  •  囚心锁ツ
    2020-12-23 19:01

    This got bumped to the top because of an edit ... The answers have gotten a bit stale, and not as useful today as another solution has been added to the standard.

    There is now an "all" shorthand property.

    #elementId select.funTimes {
       all: initial;
    }
    

    This sets all css properties to their initial value ... note some of the initial values are inherit; Resulting in some formatting still taking place on the element.

    Because of that pause required when reading the code or reviewing it in the future, don't use it unless you most as the review process is a point where errors/bugs can be made! when editing the page. But clearly if there are a large number of properties that need to be reset, then "all" is the way to go.

    Standard is online here: https://drafts.csswg.org/css-cascade/#all-shorthand

提交回复
热议问题