我想在屏幕中间设置一些东西
感谢
答案 0 :(得分:150)
$(window).height(); // returns height of browser viewport
$(document).height(); // returns height of HTML document
答案 1 :(得分:5)
与响应式网站一起使用(在移动设备或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
答案 2 :(得分:2)
$(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>