CSS: Width and Max-Width

后端 未结 9 1472
無奈伤痛
無奈伤痛 2020-12-02 18:01

Why does:

width: 98%;
max-width: 1140px;

do the same as

width: 1140px;
max-width: 98%;

The first one make

9条回答
  •  伪装坚强ぢ
    2020-12-02 18:12

    If you set a fixed width and a max-width, this means the following:

    If the width goes above max-width, keep it at max-width. If the width is below max-width, keep it on width.

    It will never go over the max-width, that doesn't mean it can't stay under, the max keyword obviously indicates a limit and not a rule.

提交回复
热议问题