Why use percentage value for div's width in CSS?

前端 未结 8 1858
无人及你
无人及你 2021-02-13 11:09

I am reading articles about css. I found out that many of writers suggest to use % value for div\'s width or height.

I am using pixels all the time.

Why should I

8条回答
  •  感动是毒
    2021-02-13 11:51

    Because if it's percentage based content flows making it easier to implement a responsive site (easier = (less (time = money))).

    Drop the relevant floats, sort out your menus and and anything else after dropping in some media queries and you've got a site working on different resolutions and devices.

    I use a fluid grid system using percentages and a ems for text sizes. Pixels are easier to work with but not in responsive terms. I do wrap my size in max width container.

    PS

    Remember though everything boils down to pixels in the end.

提交回复
热议问题