jquery仿花瓣网瀑布流实例模板

2019-03-06 19:05|来源: -- --

jquery仿花瓣网瀑布流实例模板效果如下:


使用到的插件:

jquery.js

jquery.masonry.js

jquery.infinitescroll.js


jquery masonry与infinitescroll两款瀑布流插件制作当下最流行的瀑布流图片展示实例,通过鼠标滚动图片无限加载的类似瀑布的效果的图片展示。


html的基本代码:

<div class="item_list infinite_scroll">
 
    <div class="item masonry_brick">
        <div class="item_t">
            <div class="img">
                <a href=""><img width="210" height="285" src="images/pic/01.jpg" /></a>
                <span class="price">¥195.00</span>
                <div class="btns">
                    <a href="" class="img_album_btn">加入专辑</a>
                </div>
            </div>
            <div class="title"><span>js lazyload实现网页图片延迟加载特效</span></div>
        </div>
        <div class="item_b clearfix">
            <div class="items_likes fl">
                <a href="" class="like_btn"></a>
                <em class="bold">916</em>
            </div>
            <div class="items_comment fr"><a href="">评论</a><em class="bold">(0)</em></div>
        </div>
    </div><!--item end-->



主要的jquery代码:

function item_masonry(){ 
    $('.item img').load(function(){ 
    $('.infinite_scroll').masonry({ 
        itemSelector: '.masonry_brick',
        columnWidth:226,
        gutterWidth:15                              
    });     
    }); 
    $('.infinite_scroll').masonry({ 
    itemSelector: '.masonry_brick',
    columnWidth:226,
    gutterWidth:15                              
    }); 
}
   
$(function(){
    function item_callback(){   
        $('.item').mouseover(function(){
        $(this).css('box-shadow', '0 1px 5px rgba(35,25,25,0.5)');
        $('.btns',this).show();
    }).mouseout(function(){
        $(this).css('box-shadow', '0 1px 3px rgba(34,25,25,0.2)');
        $('.btns',this).hide();         
    });
    item_masonry(); 
    }
    item_callback();  
   
    $('.item').fadeIn();
    var sp = 1
    $(".infinite_scroll").infinitescroll({
        navSelector     : "#more",
        nextSelector    : "#more a",
        itemSelector    : ".item",
        loading:{
        img: "images/masonry_loading_1.gif",
        msgText: ' ',
        finishedMsg: '木有了',
        finished: function(){
            sp++;
            if(sp>=10){ //到第10页结束事件
            $("#more").remove();
            $("#infscr-loading").hide();
            $("#page").show();
            $(window).unbind('.infscr');
            }
        }   
        },errorCallback:function(){ 
        $("#page").show();
        }
    },function(newElements){
        var $newElems = $(newElements);
        $('.infinite_scroll').masonry('appended', $newElems, false);
        $newElems.fadeIn();
        item_callback();
        return;
    });
});


相关问答

更多
  • 有JAVA功能才能使用
  • masonry 跟jQuery没有任何关系。 它是通过已经布局完成的块元素的宽高度来计算并且进行绝对定位的。
  • TFS中的流程是指用于创建团队项目的一组相互依赖的文件。 TFS中有三个默认进程:敏捷,CMMI和Scrum。 它们主要在它们提供的用于规划和跟踪工作的工作项目类型(WIT)方面有所不同。 Scrum是最轻量级的,CMMI代表能力成熟度模型集成,为正式流程和变更管理提供最多的支持。 您可以查看下面的文章以获取有关TFS过程的更多信息: https://www.visualstudio.com/en-us/docs/work/guidance/choose-process The Process in TFS ...
  • 您可以使用std :: function(在C ++ 11中)或boost :: function来存储可调用对象(函数,仿函数)。 它实现了类型擦除模式。 class C { public: template void foo(Func fun) { _myFunc = fun; } void someOtherThing() { _myFunc(); } private: std::function _myFu ...
  • 我不确定你想要实现什么,但你可能想要研究: Boost.Function - 可以包装任何类型的可调用 Boost.Bind - 可用于将成员函数绑定到实例 I am not exactly sure what you are trying to achieve, but you may want to look into: Boost.Function - can wrap any kind of callable Boost.Bind - can be used to bind a member fun ...
  • 涉及的模板参数处理从流中读取/写入的字符类型。 cout(和cin,cerr,clog)类似于: namespace std { basic_ostream cout; basic_ostream cerr; basic_ostream clog; basic_istream cin; } 还有一些版本可以读写宽字符: namespace std { basic_ostream wcout; ...
  • 您可以将任何函数对象存储在std::function 。 这需要直接存储函数指针(如果它是普通函数)或将其包装在某个对象中。 这是实现shared_ptr删除器的一种可能方式,而不需要将函数类型作为模板类型的一部分。 示例(未经测试,只是为了给你一个想法) // This is the struct which actually holds the shared pointer // A shared_ptr would reference count this template ...
  • 首先, 不要把脚本放在头脑中: 在哪里放置javascript链接 其次,瀑布似乎有些奇怪 。 医生说: colMinWidth:240px最小列宽,以像素为单位,用作计算列数的基础。 目前仅接受像素值。 如果value未定义 - 它首先尝试解析css min-width,如果失败则会降低到默认值240px。 但是,使用它默认colMinWidth为0 。 奇怪。 但是不要放弃! 您可以在构造函数中指定自己的默认值: $('.some-container').waterfall({ colMinWidt ...
  • 这是最令人烦恼的解决问题。 您需要在构造函数参数的周围添加另一对括号,否则该行将被视为函数声明。 thread > t_a((adapter(&show_hello))); 另外,考虑使用boost::thread ,因为它会将你的代码转换为三boost::thread 。 This is the Most Vexing Parse problem. You need to add another pair of parenthe ...