How do you make a webpage change its width automatically?

后端 未结 8 1203
故里飘歌
故里飘歌 2021-01-23 00:26

In HTML, is there a way to make a webpage expand to the user\'s monitor? Like say I have a 15inch, but someone else has a 24 inch. The webpage would be small on their screen,

8条回答
  •  醉酒成梦
    2021-01-23 00:53

    Unless you specify a specific width for any element of a webpage, such as the body or some containing div, it will expand to the width of the browser window.

    If you're looking to set the size in pixels to the user's width, you can use javascript to set widths dynamically:

    
    

    However, you should probably use a more fluid layout that will automatically expand by using widths specified in percents (e.g. setting the width of an element with CSS: width: 100%)

提交回复
热议问题