CSS - Percentages or Pixels?

前端 未结 9 767
梦如初夏
梦如初夏 2020-12-04 21:54

I have been using CSS for many years now, and I have always been a \'percentage\' kind of guy, as in I always define heights and widths using percentages as opposed to pixel

9条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 22:40

    Use Both =D

    With You can always combine using both if you are confused about it)

    calc() is a native CSS way to do simple math right in CSS as a replacement for any length value (or pretty much any number value).

    It has four simple math operators: add (+), subtract (-), multiply (*), and divide (/).

    .my-class {
        widht: calc(100% - 20px);
        height: calc(50% + 10px);
    }
    

    Browser Support is surprisingly good. Can I use...

    Useful reading: CSS-Tricks

提交回复
热议问题