Как получить "высоту" экрана с помощью jquery Я хочу установить что-то посредине экрана спасибо Ответ 1 $(window).height(); // returns height of browser viewport $(document).height(); // returns height of HTML document Как описано здесь: http://api.jquery.com/height/ Ответ 2 использовать с отзывчивым веб-сайтом (просмотр на мобильном телефоне или ipad) jQuery(window).height(); // return height of browser viewport jQuery(window).width(); // return width of browser viewport редко используют jQuery(document).height(); // return height of HTML document jQuery(document).width(); // return width of HTML document Ответ 3 $(window).height(); Чтобы установить что-нибудь в середине, вы можете использовать CSS. <style> #divCentre { position: absolute; left: 50%; top: 50%; width: 300px; height: 400px; margin-left: -150px; margin-top: -200px; } </style> <div id="divCentre">I am at the centre</div>
Ответ 1 $(window).height(); // returns height of browser viewport $(document).height(); // returns height of HTML document Как описано здесь: http://api.jquery.com/height/
Ответ 2 использовать с отзывчивым веб-сайтом (просмотр на мобильном телефоне или ipad) jQuery(window).height(); // return height of browser viewport jQuery(window).width(); // return width of browser viewport редко используют jQuery(document).height(); // return height of HTML document jQuery(document).width(); // return width of HTML document
Ответ 3 $(window).height(); Чтобы установить что-нибудь в середине, вы можете использовать CSS. <style> #divCentre { position: absolute; left: 50%; top: 50%; width: 300px; height: 400px; margin-left: -150px; margin-top: -200px; } </style> <div id="divCentre">I am at the centre</div>