【发布时间】:2014-09-18 20:43:24
【问题描述】:
我有一个 html div 元素,我想将其静态定位,但我事先不知道该放在哪里。因此,当我想将其修复到当前位置时,我会使用这个绝妙的技巧:
var pos = $('#id_of_div').offset();
$('#id_of_div').css('position','fixed').css(pos);
它在我试过的所有浏览器上都能完美运行,除了 IE。有什么建议吗?
【问题讨论】:
-
你用的是什么版本的IE(ps检查兼容模式)
-
position: fixed被 IE7+ 识别(使用触发标准模式的 DOCTYPE)。你真的需要支持 IE6 吗? -
请务必使用支持 IE 的正确版本的 jQuery。您可能需要添加如下内容:
<!--[if lt IE 9]> <script type="text/javascript" src="/resources/lib/jquery/js/jquery-1.11.0.min.js"></script> <![endif]-->
标签: javascript jquery css internet-explorer css-position