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

前端 未结 8 1856
无人及你
无人及你 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

    It's not clear which context you are referring to (what type of elements). However, you need to be careful when using pixels for font sizes.

    I generally use pixels for divs to keep my layout as expected. But I avoid pixels for fonts. Different users may want the font at different sizes. Why take that away.

提交回复
热议问题