【问题标题】:Jquery Make Flash 100% fit to DIVJquery 使 Flash 100% 适合 DIV
【发布时间】:2009-08-29 16:08:06
【问题描述】:

我已经设法重写了一个脚本,该脚本使图像调整为其父 Div 容器的 100% 宽度到一个脚本,现在允许 Swf 嵌入对象调整大小(原始图像调整脚本由 Oliver Boermans olicle.c o m/eg/jquery/imagefit/)

我所做的只是在 img 标签的参数应该替换宽度和高度值的所有行中用“嵌入”替换 img。

在 Firefox 中一切正常,但在 IE 7 中完全没有运气。

Here a link to my Project

观看在 Firefox 中调整大小的 Flash 视频,而 IE 7 显示错误。

这是我的 jquery js 函数:

(function($) {
$.fn.imagefit = function(options) {
    var fit = {
        all : function(imgs){
            imgs.each(function(){
                fit.one(this);
                })
            },
        one : function(img){
            $(img)
                .width('100%').each(function()
                {
                    $(this).height(Math.round(
                        $(this).attr('startheight')*($(this).width()/$(this).attr('startwidth')))
                    );
                })
            }
    };

    this.each(function(){
            var container = this;

            // store list of contained images (excluding those in tables)
            var imgs = $('img', container).not($("table img"));

            // store initial dimensions on each image 
            imgs.each(function(){
                $(this).attr('startwidth', $(this).width())
                    .attr('startheight', $(this).height())
                    .css('max-width', $(this).attr('startwidth')+"px");

                fit.one(this);
            });
            // Re-adjust when window width is changed
            $(window).bind('resize', function(){
                fit.all(imgs);
            });
        });
    return this;
};

})(jQuery);

每个函数负责遍历我从触发函数调用的所有 div:jQuery(document).ready(function(){ jQuery('.widget-content').flashfit(); });

我怎样才能使它也适用于 Internet Explorer 和 Chrome?有什么想法吗?

【问题讨论】:

标签: jquery flash internet-explorer image resize


【解决方案1】:

您是否考虑过使用 swffit 代替?这对于调整容器内的 Flash 大小以及全浏览器大小的 Flash 文件都非常有效。

http://swffit.millermedeiros.com/

另外需要考虑的是 Flash 文件的实际结构,它应该被设置为根据舞台大小更新元素的位置,否则事情会变得非常丑陋。

希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 2013-10-18
    • 1970-01-01
    • 1970-01-01
    • 2021-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多