Square DIV where height is equal to viewport

前端 未结 8 1299
我在风中等你
我在风中等你 2020-12-01 06:13

I need to create a DIV where width=height, and height=100% of the viewport (which, obviously, is variable).

In other words, a perfectly sq

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 06:41

    You could use Javascript and get the screen size. After which you could set width and height accordingly.

    window.screen.width, and window.screen.height should work.

    You could then use this information and generate a tiny bit of CSS for the page to be displayed accordingly.

提交回复
热议问题