我正在编写跨浏览器视图效果的jQuery动画。我需要用黑客属性_height和*height来处理IE。我尝试使用以下命令设置属性
$('#notice_container').css({'_margin-bottom':'auto', 'margin-bottom': '31px'});但它不会像我指定的那样设置_margin-bottom,而是设置了margin-bottom。
那么,我的问题是如何使用jQuery设置这些IE指定的属性?
发布于 2011-11-17 16:16:17
虽然不能直接回答如何使用jQuery实现传统的IE CSS hack,但您可能会对一个更简洁的解决方案感兴趣,如下所示:
http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
基本上,您可以使用条件注释将类分配给html元素,具体取决于运行的IE版本:
<!--[if lt IE 7]> <html class="ie6"> <![endif]-->
<!--[if IE 7]> <html class="ie7"> <![endif]-->
<!--[if IE 8]> <html class="ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->然后像这样定位元素,而不是使用hack:
$('.ie7 #notice_container').css({'margin-bottom':'auto'});如果需要,可以选择ids或不同的类名。一般来说,这是一种非常干净的“黑客攻击”IE的方法。
发布于 2011-11-17 16:15:26
你可以尝试的原因是
if( $.browser.msie && $.browser.version == 7.0 )
{
$('#notice_container').css({'margin-bottom':'auto'});
}发布于 2011-11-17 16:12:34
您可以尝试直接设置样式属性:
.attr({'style':'_margin-bottom:auto;margin-bottom:31px'});https://stackoverflow.com/questions/8163900
复制相似问题