如何使用jquery在浏览器内容查看区域周围设置边框? [英] How to put a border around the browser content viewing area using jquery?
本文介绍了如何使用jquery在浏览器内容查看区域周围设置边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
如何在不滚动的情况下获取浏览器窗口大小酒吧
Possible Duplicate:
how to get the browser window size without the scroll bars
如何使用jquery在浏览器内容查看区域周围设置边框?
How to put a border around the browser content viewing area using using jquery?
这是我尝试过的.
var $windowW = $(window).width();
var $windowH = $(window).height();
alert($windowW + " " + $windowH); // THe results are width 1440 and 745 height
$("body").css("width", $windowW);
$("body").css("height", $windowH);
$("body").css("border","1px solid green");
我在文档正文中没有元素,也没有收到 宽度1440和高度745周围的绿色边框.
I have no elements in the body of the document and I am not getting a green border around the width of 1440 and height of 745.
如何使用来自的返回值在浏览器的可见区域周围放置边框 使用jQuery的$ windowW和$ windowH?
How do I put a border around the viewable area of the browser using the return values from $windowW and $windowH using jquery?
推荐答案
您可以使用CSS和绝对定位"更轻松地做到这一点:
You can do it more easily using CSS and Absolute Positioning:
body
{
border: 2px solid green;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: auto;
}
请参见小提琴.
这篇关于如何使用jquery在浏览器内容查看区域周围设置边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文