jquery - 为什么内容在 IE7 中不环绕 float 图像?

标签 jquery css internet-explorer-7

参见:http://hostingcouponsclub.com/codero-coupons .

当我点击 more<< (红色投票部分上方)为什么在 IE7 下内容不环绕图像?

在 Firefox 和 Chrome 下,没问题。

单击红色 more<< 时如何使内容环绕图像IE7 中的文本?

最佳答案

这是因为当 jQuery 动画时(你的显示/隐藏函数使用“慢”)它导致动画元素“获得布局”这反过来导致文本不换行:Reference

例如你的pr_content div 使用内联样式实现类似这样的东西(在 IE7 中,在 IE8 中不同)

<div style="filter: ; zoom: 1; display: block" class="pr_content">

有各种修复,但也有各种错误,我尝试了一些不同的修复,比如删除过滤器,但 removeAttr() 函数也有一个错误,我想也许可以删除 style attribute并使用 .css()申请display:blockdisplay: none;可能有用,但没有乐趣,尽管 YMMV

这是您现有的 jQuery:(来自 idccoupon/scripts.js)

$('.pr_content').hide();
$('.moreteaser').click(function() { 
     $('.pr_teaser').hide();
     $('.pr_content').toggle("slow");
     $(".pr_content").attr("zoom","");
  $('.moreteaser, .lessteaser').toggle();
});

$('.lessteaser').click(function() { 
     $('.pr_content').toggle("slow");
     $('.pr_teaser').show();
     $('.moreteaser, .lessteaser').toggle();

});

注:attr("zoom", "");我知道这是针对此问题的推荐修复方法,无法删除 zoom据我所知,这是我在尝试删除其他属性时发现的。

通过删除仅针对 IE 的“慢速”命令,我完成了一半的工作(即没有针对 IE 的增强功能),只是意味着他们获得了即时显示/隐藏而不是“平滑”的。这或只是让 IE 用户像他们刚才那样获取未包装的内容可能是最简单的解决方案?

无论如何,这是我使用的代码,以防您想尝试:

$('.pr_content, .lessteaser').hide();

$('.moreteaser, .lessteaser').click (function() { 
    if (jQuery.browser.msie) {
         $('.pr_content, .prteaser, .moreteaser, .lessteaser').toggle();
    } else {
         $('.pr_content, .prteaser, .moreteaser, .lessteaser').toggle("slow");
    }   
});

关于jquery - 为什么内容在 IE7 中不环绕 float 图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5910266/

相关文章:

css - <button> 标签有什么缺点?

javascript - 不显示 PHP 表单操作页面

javascript - 使用jquery将每行1列的表变成每行2列的表

javascript - MediaElement.js 音频播放器 - 有趣的移动包装

css - Div定位不明确

javascript - 如何为 CakePhp 添加外部 Javascript 和 CSS

html - 跨度、按钮和 IE7 float 错误

javascript - 窗口调整大小事件在 ie7 中不断触发

jquery 进度条不工作

javascript - 在特定日期使用 jquery 显示图像,并且在这一天之后不显示