我使用 this plugin来显示书籍,这个结果显示出良好的效果
IE浏览器和Chrome浏览器但结果在Mozilla Firefox中表现不佳!可能是什么原因 ?

> Good image- Chrome browser
> Not good image- Mozilla Firefox

*Live demo *

码:

<script type="text/javascript">
        $(document).ready(function () {
            $('#pinBoot').pinterest_grid({
                no_columns: 6,padding_x: 10,padding_y: 10,margin_bottom: 50,single_column_breakpoint: 700
            });
        });

        (function ($,window,document,undefined) {
            var pluginName = 'pinterest_grid',defaults = {
                        padding_x: 10,no_columns: 3,single_column_breakpoint: 700
                    },columns,$article,article_width;

            function Plugin(element,options) {
                this.element = element;
                this.options = $.extend({},defaults,options);
                this._defaults = defaults;
                this._name = pluginName;
                this.init();
            }

            Plugin.prototype.init = function () {
                var self = this,resize_finish;

                $(window).resize(function () {
                    clearTimeout(resize_finish);
                    resize_finish = setTimeout(function () {
                        self.make_layout_change(self);
                    },11);
                });

                self.make_layout_change(self);

                setTimeout(function () {
                    $(window).resize();
                },500);
            };

            Plugin.prototype.calculate = function (single_column_mode) {
                var self = this,tallest = 0,row = 0,$container = $(this.element),container_width = $container.width();
                $article = $(this.element).children();

                if (single_column_mode === true) {
                    article_width = $container.width() - self.options.padding_x;
                } else {
                    article_width = ($container.width() - self.options.padding_x * self.options.no_columns) / self.options.no_columns;
                }

                $article.each(function () {
                    $(this).css('width',article_width);
                });

                columns = self.options.no_columns;

                $article.each(function (index) {
                    var current_column,left_out = 0,top = 0,$this = $(this),prevAll = $this.prevAll(),tallest = 0;

                    if (single_column_mode === false) {
                        current_column = (index % columns);
                    } else {
                        current_column = 0;
                    }

                    for (var t = 0; t < columns; t++) {
                        $this.removeClass('c' + t);
                    }

                    if (index % columns === 0) {
                        row++;
                    }

                    $this.addClass('c' + current_column);
                    $this.addClass('r' + row);

                    prevAll.each(function (index) {
                        if ($(this).hasClass('c' + current_column)) {
                            top += $(this).outerHeight() + self.options.padding_y;
                        }
                    });

                    if (single_column_mode === true) {
                        left_out = 0;
                    } else {
                        left_out = (index % columns) * (article_width + self.options.padding_x);
                    }

                    $this.css({
                        'left': left_out,'top': top
                    });
                });

                this.tallest($container);
                $(window).resize();
            };

            Plugin.prototype.tallest = function (_container) {
                var column_heights = [],largest = 0;

                for (var z = 0; z < columns; z++) {
                    var temp_height = 0;
                    _container.find('.c' + z).each(function () {
                        temp_height += $(this).outerHeight();
                    });
                    column_heights[z] = temp_height;
                }

                largest = Math.max.apply(Math,column_heights);
                _container.css('height',largest + (this.options.padding_y + this.options.margin_bottom));
            };

            Plugin.prototype.make_layout_change = function (_self) {
                if ($(window).width() < _self.options.single_column_breakpoint) {
                    _self.calculate(true);
                } else {
                    _self.calculate(false);
                }
            };

            $.fn[pluginName] = function (options) {
                return this.each(function () {
                    if (!$.data(this,'plugin_' + pluginName)) {
                        $.data(this,'plugin_' + pluginName,new Plugin(this,options));
                    }
                });
            }

        })(jQuery,document);
    </script>

html / PHP代码

<div class="row"> 
    <section id="pinBoot"> 
        <?PHP
        if (empty($query4)) {
            echo '<p style="color:red;">&nbsp;&nbsp;&nbsp;&nbsp;No Books To display!</p>';
        } else {
            foreach ($query4 as $row) {
                ?>
                <article class="white-panel">
                <?PHP echo "<img src='" . base_url() . "uploads/books/$row->img1' alt='.$row->book_title.'  title='$row->book_title By $row->auth_firstname $row->auth_lastname' />"; ?>
                <h4>
                <a class="title" href="#">
                <?PHP echo "$row->book_title"; ?>
                </a>
                </h4> 
                <left> <img src="http://www.homequalitymark.com/filelibrary/interactive_scorecard/4_star.png" style="width:50%;height:12px;"/></left>
                <p> By 
                <a class="link" href="" title="<?PHP echo $row->book_title ?>">
                <?PHP
                $afl = $row->auth_firstname . ' ' . $row->auth_lastname;
                $tafln = strlen($afl);
                if ($tafln >= 15) {
                    $afln = strip_tags($afl);
                    $safln = substr($afln,11);
                    echo "<span class='author'>$safln ...</span>";
                } else {
                    echo "<span title='$row->auth_firstname $row->auth_lastname' class='author'> $row->auth_firstname $row->auth_lastname</span>";
                }
                ?> 
                </a> <br/>
                Number of Pages:<?PHP echo $row->pages; ?>
                </p>   
                <a href="#" class="btn btn-default btn-xs rent-btn" data-id="<?PHP echo $row->book_id; ?>"   role="button">Rent</a>
                <a href="#" class="btn btn-default btn-xs rent-btn" role="button">Add to Wishlist</a>
                </p>
                </article> 
                <?PHP


            }
        }
        ?>  
    </section> 
    <hr> 
    <div id="divId">

    </div>
</div>
编辑:我添加了说明.

未给出示例中使用的CSS“row”和“pinBoot”选择器规则.

<div class="row"> 
    <section id="pinBoot">

我已经使用并尝试过原始的CSS选择器.问题可能在于“row”和“pinBoot”选择器.

<div class="container marketing">
  <section id="blog-landing">

将“容器”添加到“行”类时也可以使用它.

<div class = "container"> or <div class = "row container">

对不起英语不好,我无法解释更多.我希望我能说出来.

请测试,例如.代码创建PHP文件.

<!DOCTYPE html>
<html lang="en">
<head>
<Meta charset="utf-8">
<Meta http-equiv="X-UA-Compatible" content="IE=edge">
<Meta name="viewport" content="width=device-width,initial-scale=1">
<title>jQuery Pinterest Grid Plugin Example</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<style>
body {
  background: #E9E9E9;
}
#blog-landing {
  margin-top: 81px;
  position: relative;
  max-width: 100%;
  width: 100%;
}
img {
  width: 100%;
  max-width: 100%;
  height: auto;
}
.white-panel {
  position: absolute;
  background: white;
  Box-shadow: 0px 1px 2px rgba(0,0.3);
  padding: 10px;
}
.white-panel h1 {
  font-size: 1em;
}
.white-panel h1 a {
  color: #A92733;
}
.white-panel:hover {
  Box-shadow: 1px 1px 10px rgba(0,0.5);
  margin-top: -5px;
  -webkit-transition: all 0.3s ease-in-out;
  -moz-transition: all 0.3s ease-in-out;
  -o-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
}
</style>
<link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
</head>
<!-- NAVBAR
================================================== -->
<body>


<?PHP
$query4 = array(
    array(
        'img1' => 'http://www.mediademon.com/wp-content/uploads/2014/04/food-drink-expo.png','book_title' => 'Is your website converting visits into sales?','auth_firstname' => 'Roberto','auth_lastname' => 'Doleto','pages' => '23','book_id' => '2'
    ),array(
        'img1' => 'http://www.mediademon.com/wp-content/uploads/2014/04/food-drink-expo.png','book_id' => '2'
    )
);

$query4 = json_decode(json_encode($query4));

?>


<h1 style="margin-top:150px" align="center">jQuery Pinterest Grid Plugin Example</h1>
<div class="container marketing">
<section id="blog-landing">

<?PHP foreach ($query4 as $row) { ?>

<article class="white-panel">

<?PHP echo "<img src='{$row->img1}' alt='.{$row->book_title}.'  title='{$row->book_title} By {$row->auth_firstname} {$row->auth_lastname}' />"; ?>
<h4><a href="#"><?PHP echo "$row->book_title"; ?></a></h4>
<p>

<a class="link" href="" title="<?PHP echo $row->book_title ?>">
<?PHP
$afl = $row->auth_firstname . ' ' . $row->auth_lastname;
$tafln = strlen($afl);
if ($tafln >= 15) {
    $afln = strip_tags($afl);
    $safln = substr($afln,11);
    echo "<span class='author'>$safln ...</span>";
} else {
    echo "<span title='{$row->auth_firstname} {$row->auth_lastname}' class='author'> {$row->auth_firstname} {$row->auth_lastname}</span>";
}
?> 
</a> <br/>
Number of Pages:<?PHP echo $row->pages; ?>

</p>
<p>
<a href="#" class="btn btn-default btn-xs rent-btn" data-id="<?PHP echo $row->book_id; ?>"   role="button">Rent</a>
<a href="#" class="btn btn-default btn-xs rent-btn" role="button">Add to Wishlist</a>
</p>
</article>

<?PHP } ?>

</section>
</div>



<!-- Bootstrap core JavaScript
    ================================================== --> 
<!-- Placed at the end of the document so the pages load faster --> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="http://www.jqueryscript.net/demo/Simple-jQuery-Plugin-To-Create-Pinterest-Style-Grid-Layout-Pinterest-Grid/pinterest_grid.js"></script> 
<script>
        $(document).ready(function() {

            $('#blog-landing').pinterest_grid({
                no_columns: 4,single_column_breakpoint: 700
            });

        });
    </script>
</body>
</html>

php – Div在Mozilla firefox中表现不佳的更多相关文章

  1. 从iOS应用程序发送帖子到PHP脚本不工作…简单的解决方案就像

    我之前已经做了好几次了但是由于某些原因我无法通过这个帖子…我尝试了设置为_POST且没有的变量的PHP脚本……当它们未设置为发布时它工作精细.这是我的iOS代码:这里是PHP的一大块,POST变量不在正确的位置?我想这对于更有经验的开发人员来说是一个相当简单的答案,感谢您的帮助!解决方法$_POST是一个数组,而不是一个函数.您需要使用方括号来访问数组索引:

  2. swift学习2 元组 tuples

    swift中出现了一种新的数据结构,非常牛掰的元组tuples如果懂PHP的猿,会发现这个元组和PHP的数组非常类似,同样是可以默认不指定key,也可以指定key目前的学习疑问是,如何进行元组的遍历?

  3. 尝试使用swift mailer,gmail smtp,php发送邮件

    这里是我的代码:在运行时出现此错误…

  4. Android:从应用程序内启动Firefox

    只是想知道是否有人知道启动Firefox移动浏览器的正确意图.我无法在任何地方找到它,所以我希望有人知道.谢谢解决方法这将为Firefox创建一个意图:

  5. Android的Firefox源代码

    我最近看到了FirefoxforAndroid的发布.似乎firefox有几个很棒的功能和性能改进.我想知道Android平台的源代码是否已经发布,如果是,我可以在哪里获得最新的源代码?

  6. PHP使用JpGraph绘制折线图操作示例【附源码下载】

    这篇文章主要介绍了PHP使用JpGraph绘制折线图操作,结合实例形式分析了php使用JpGraph的相关操作技巧与注意事项,并附带源码供读者下载参考,需要的朋友可以参考下

  7. jQuery的Cookie封装,与PHP交互的简单实现

    下面小编就为大家带来一篇jQuery的Cookie封装,与PHP交互的简单实现。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

  8. PHP+jquery+CSS制作头像登录窗(仿QQ登陆)

    本篇文章介绍了PHP结合jQ和CSS制作头像登录窗(仿QQ登陆),实现了类似QQ的登陆界面,很有参考价值,有需要的朋友可以了解一下。

  9. 如何在PHP环境中使用ProtoBuf数据格式

    这篇文章主要介绍了如何在PHP环境中使用ProtoBuf数据格式,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

  10. PHP rsa加密解密算法原理解析

    这篇文章主要介绍了PHP rsa加密解密算法原理解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

随机推荐

  1. PHP个人网站架设连环讲(一)

    先下一个OmnihttpdProffesinalV2.06,装上就有PHP4beta3可以用了。PHP4给我们带来一个简单的方法,就是使用SESSION(会话)级变量。但是如果不是PHP4又该怎么办?我们可以假设某人在15分钟以内对你的网页的请求都不属于一个新的人次,这样你可以做个计数的过程存在INC里,在每一个页面引用,访客第一次进入时将访问时间送到cookie里。以后每个页面被访问时都检查cookie上次访问时间值。

  2. PHP函数学习之PHP函数点评

    PHP函数使用说明,应用举例,精简点评,希望对您学习php有所帮助

  3. ecshop2.7.3 在php5.4下的各种错误问题处理

    将方法内的函数,分拆为2个部分。这个和gd库没有一点关系,是ecshop程序的问题。会出现这种问题,不外乎就是当前会员的session或者程序对cookie的处理存在漏洞。进过本地测试,includes\modules\integrates\ecshop.php这个整合自身会员的类中没有重写integrate.php中的check_cookie()方法导致,验证cookie时返回的username为空,丢失了登录状态,在ecshop.php中重写了此方法就可以了。把他加到ecshop.php的最后面去就可

  4. NT IIS下用ODBC连接数据库

    $connection=intodbc_connect建立数据库连接,$query_string="查询记录的条件"如:$query_string="select*fromtable"用$cur=intodbc_exec检索数据库,将记录集放入$cur变量中。再用while{$var1=odbc_result;$var2=odbc_result;...}读取odbc_exec()返回的数据集$cur。最后是odbc_close关闭数据库的连接。odbc_result()函数是取当前记录的指定字段值。

  5. PHP使用JpGraph绘制折线图操作示例【附源码下载】

    这篇文章主要介绍了PHP使用JpGraph绘制折线图操作,结合实例形式分析了php使用JpGraph的相关操作技巧与注意事项,并附带源码供读者下载参考,需要的朋友可以参考下

  6. zen_cart实现支付前生成订单的方法

    这篇文章主要介绍了zen_cart实现支付前生成订单的方法,结合实例形式详细分析了zen_cart支付前生成订单的具体步骤与相关实现技巧,需要的朋友可以参考下

  7. Thinkphp5框架实现获取数据库数据到视图的方法

    这篇文章主要介绍了Thinkphp5框架实现获取数据库数据到视图的方法,涉及thinkPHP5数据库配置、读取、模型操作及视图调用相关操作技巧,需要的朋友可以参考下

  8. PHP+jquery+CSS制作头像登录窗(仿QQ登陆)

    本篇文章介绍了PHP结合jQ和CSS制作头像登录窗(仿QQ登陆),实现了类似QQ的登陆界面,很有参考价值,有需要的朋友可以了解一下。

  9. 基于win2003虚拟机中apache服务器的访问

    下面小编就为大家带来一篇基于win2003虚拟机中apache服务器的访问。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

  10. Yii2中组件的注册与创建方法

    这篇文章主要介绍了Yii2之组件的注册与创建的实现方法,非常不错,具有参考借鉴价值,需要的朋友可以参考下

返回
顶部