Square DIV where height is equal to viewport

前端 未结 8 1316
我在风中等你
我在风中等你 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:49

    You can do this with jquery (or pure javascript if you prefer).

    With jquery:

    $(document).ready(function(){ var height = $(window).height(); $('#square').css('height', height); $('#square').css('width', height); });

提交回复
热议问题