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

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

    Save the following html to a file and open it with your web browser. Now change the size of the web browser window, notice the percent will expand and contract and the pixels don't.

    
    
    
    Pixels and Percents
    
    
    
    
    PIXELS
    PERCENT

提交回复
热议问题