CSS width 100% OR max-width in pixels

前端 未结 3 1870
暖寄归人
暖寄归人 2020-12-05 09:13

How one could create a CSS rule for width which

  • Uses 100% width by default

  • If 100% width exceeds certain pixel width (let\'s say 512 px), th

3条回答
  •  有刺的猬
    2020-12-05 09:51

    If it's block level element it should be 100% by default so no need to declare the width, then max-width: 512px; would curtail it

    calc() is not supported very well at all, but in this case I wouldn't think you would need it

提交回复
热议问题