What's the difference between `all: unset` and `all: revert'

后端 未结 3 1639
生来不讨喜
生来不讨喜 2020-12-02 02:20

As per MDN:

The revert keyword works exactly the same as unset in many cases. The only difference is for properties that have values set by the brow

3条回答
  •  一向
    一向 (楼主)
    2020-12-02 02:52

    revert and unset are identical except when the default css value for a property is different than the value set by the browser - or by custom stylesheets created by the user.

    For example the css default value for display is inline for all elements including divs, so if you set display:unset, it will act as if display:initial which is the same as display:inline, however we know that browsers set display:block for divs.

    This div use unset, now divs display will be inline

    text
    text

    This div use revert, now divs display will be block (the browser value or the value created by the user)

    text
    text

提交回复
热议问题