How do you make a webpage change its width automatically?

后端 未结 8 1056
故里飘歌
故里飘歌 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:47

    HTML ist just a markup language to describe the meaning of (textual) contents. For example,

    Foobar

    just means Foobar is a first level heading but doesn’t tell anything about the style it should to be displayed.

    For styling a HTML document the Cascading Style Sheets (CSS) has been introduced. But CSS is also just a describtive language and doesn’t know anything about the user agent. (You could just describe that specific elements should be displayed with a specific width and so on.)

    But JavaScript does know the user agent. You could use the screen object to obtain the width and height of the screen or the available viewport.

提交回复
热议问题