适当的IE6 HTML元素维度 [英] Proper IE6 HTML element dimensions

查看:86
本文介绍了适当的IE6 HTML元素维度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用javascript设置元素的宽度和高度以覆盖整个浏览器视口,并且我成功使用

I'm trying to set the width and height of an element with javascript to cover the entire browser viewport, and I'm successful using

document.body.clientHeight

但是在IE6中,似乎我总是得到水平和垂直滚动条,因为元素必须略大。

but in IE6 it seems that I always get horizontal and vertical scrollbars because the element must be slightly too big.

现在,我真的不想使用特定于浏览器的逻辑,只为IE6从每个维度中减去一个像素或2。另外,我没有使用CSS(宽度:100%等),因为我需要像素数量。

Now, I really don't want to use browser specific logic and substract a pixel or 2 from each dimension just for IE6. Also, I am not using CSS (width: 100% etc.) for this because I need the pixel amounts.

有没有人知道更好的方法来填充视口IE6 +中的一个元素(显然也是所有优秀的浏览器)?

Does anyone know a better way to fill the viewport with an element in IE6+ (obviously all good browsers, too)?

编辑:感谢Owen的建议,我确信jQuery会起作用。我应该指出我需要一个与工具包无关的解决方案。

Thanks Owen for the suggestion, I'm sure jQuery will work. I should have specified that I need a toolkit-agnostic solution.

推荐答案

您是否考虑过使用 jQuery 的?它将大多数浏览器特定功能抽象为一个通用接口。

have you considered using jQuery? it abstracts most of the browser specific functionality away into a common interface.

var width = $(document).width();
var height = $(document.height();

$('#mySpecialElement').width(width).height(height);

这篇关于适当的IE6 HTML元素维度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆