最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

一則C#簡(jiǎn)潔瀑布流代碼

 更新時(shí)間:2014年06月11日 10:49:36   作者:  
最近想實(shí)現(xiàn)數(shù)據(jù)的延遲加載,網(wǎng)上找一下有很多例子,看了Masonry的例子啟發(fā),自己寫(xiě)了一個(gè)很簡(jiǎn)潔的代碼。分享給大家

View頁(yè)面。

復(fù)制代碼 代碼如下:

@{
        ViewBag.Title = "瀑布流";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
@section header{
    <script src="~/Scripts/jquery-ui-1.8.24.min.js"></script>
         <style type="text/css">
        .* {
         margin:0px;
         padding:0px;
        }
        body {
            margin-left:auto;
            margin-right:auto;
        }
        .ClearBoth {
            clear:both;
        }
        #bodyContent {
            width:1400px;
            margin-left:auto;
            margin-right:auto;
        }
        #head {
            width:100%;
            height:50px;
            margin-bottom:10px;
        }
        #LefMenue {
            width:20%;
            height:500px;
            float:left;
        }
        #RightContent {
            width:75%;
            float:right;
            border: thin solid #333;
        }
        #Footer {
            margin-top:10px;
            width:100%;
            height:40px;
        }
        .GreyBlock {
            border: thin solid #333;
            background-color:#CCC;
            width:100%;
        }
        .Item {
            float: left;
            width: 230px;
            margin:5px;
            border: 1px solid #CCC;
        }
        </style>
}
 <div id="bodyContent">
   <div id="head" class="GreyBlock">
     <h1>Head</h1>
   </div>
   <div>
           <!--Left-->
       <div id="LefMenue" class="GreyBlock">
         <ul>
           <li>1</li>
           <li>2</li>
           <li>3</li>
         </ul>
       </div>
       <!----right-->
       <div id="RightContent">
             <div id="ProductList">
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
               <div class="Item">
                   <dl>
                       <dt>
                           <img src="~/Content/Shose.jpg" /></dt>
                       <dd>What's up with you</dd>
                    </dl>
               </div>
             </div>
       </div>
     <div class="ClearBoth"></div>
   </div>
<div id="loading" class="loading-wrap">
    <span class="loading">加載中,請(qǐng)稍后...</span>
</div>
   <div class="ClearBoth"></div>
   <div id="Footer" class="GreyBlock"></div>
 </div>

@section scripts{
    <script type="text/javascript">
        var myContainer = $("#ProductList");
        //用戶拖動(dòng)滾動(dòng)條,達(dá)到底部時(shí)ajax加載一次數(shù)據(jù)
        var loading = $("#loading").data("on", false);//通過(guò)給loading這個(gè)div增加屬性on,來(lái)判斷執(zhí)行一次ajax請(qǐng)求
        $(window).scroll(function () {
            if ($("#loading").data("on"))//
            {
                return;
            }
            var isButtom = $(document).scrollTop() > ($(document).height() - $(window).height() - $("#Footer").height());
            if (isButtom) {//頁(yè)面拖到底部了
                //加載更多數(shù)據(jù)
                loading.data("on",true).fadeIn();
                $.get("@Url.Action("GetData","Product")", function (data) {
                    var html = CreateHtml(data);
                    var $newElems = $(html).css({ opacity: 0 }).appendTo(myContainer);
                    $newElems.animate({ opacity: 1 },3000);
                    loading.data("on", false);
                    loading.fadeOut();
                },"json");
            }
        });
        function CreateHtml(data) {
            var html = "";
            if ($.isArray(data)) {
                for (var i in data) {
                    //html += "<div class=\"Item\" style=\"height:"+data[i]+"px\">";
                    html += "<div class=\"Item\">";
                    html += "<dl>";
                    html += "<dt>";
                    html += "<img src=\"../Content/Shose.jpg\" />";
                    html += "</dt>";
                    html += "<dd>";
                    html += "What's up with you " + data[i];
                    html += "</dd>"
                    html += "</dl>"
                    html += "</div>"
                }
            }
            return html;
        }
    </script>
    }

C#服務(wù)端:

復(fù)制代碼 代碼如下:

public JsonResult GetData()
        {
            Random ro = new Random();

            List<int> vListInt = new List<int>();
            for (int i = 0; i < 12; i++)
            {
                vListInt.Add(ro.Next(400, 500));
            }
            return Json(vListInt, JsonRequestBehavior.AllowGet);
        }

相關(guān)文章

  • C#8 的模式匹配實(shí)現(xiàn)

    C#8 的模式匹配實(shí)現(xiàn)

    這篇文章主要介紹了C#8 的模式匹配實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12
  • c# 如何用組合替代繼承

    c# 如何用組合替代繼承

    這篇文章主要介紹了c# 如何用組合替代繼承,幫助大家更好的理解和學(xué)習(xí)使用c#,感興趣的朋友可以了解下
    2021-02-02
  • C#編譯器對(duì)局部變量的優(yōu)化指南

    C#編譯器對(duì)局部變量的優(yōu)化指南

    這篇文章主要給大家介紹了關(guān)于C#編譯器對(duì)局部變量的優(yōu)化指南,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • C#中的==運(yùn)算符

    C#中的==運(yùn)算符

    這篇文章主要介紹了C#中的==運(yùn)算符,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2017-06-06
  • C#中的協(xié)變與逆變深入講解

    C#中的協(xié)變與逆變深入講解

    這篇文章主要給大家介紹了關(guān)于C#中協(xié)變與逆變的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2018-12-12
  • C#中將字符串轉(zhuǎn)換為整型的三種解決方法總結(jié)

    C#中將字符串轉(zhuǎn)換為整型的三種解決方法總結(jié)

    本篇文章是對(duì)C#中將字符串轉(zhuǎn)換為整型的三種解決方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • 基于C#?wpf實(shí)現(xiàn)桌面放大鏡

    基于C#?wpf實(shí)現(xiàn)桌面放大鏡

    做桌面截屏功能時(shí)需要放大鏡,顯示鼠標(biāo)所在位置的放大圖像,所以本文為大家介紹了如何基于C#?wpf實(shí)現(xiàn)桌面放大鏡功能,有需要的小伙伴可以參考下
    2023-09-09
  • C#表達(dá)式目錄樹(shù)示例詳解

    C#表達(dá)式目錄樹(shù)示例詳解

    這篇文章主要給大家介紹了關(guān)于C#表達(dá)式目錄樹(shù)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-10-10
  • 積累Visual Studio 常用快捷鍵的動(dòng)畫(huà)演示

    積累Visual Studio 常用快捷鍵的動(dòng)畫(huà)演示

    在代碼開(kāi)發(fā)過(guò)程中,頻繁的使用鍵盤(pán)、鼠標(biāo)操作非常麻煩,影響程序的開(kāi)發(fā)效率。如何操作能用鍵盤(pán)來(lái)操作,那就節(jié)省時(shí)間了。下面小編把我平時(shí)積累的有關(guān)visul studio 常用快捷鍵的動(dòng)畫(huà)演示分享給大家,僅供大家參考
    2015-10-10
  • c#實(shí)現(xiàn)sunday算法實(shí)例

    c#實(shí)現(xiàn)sunday算法實(shí)例

    Sunday算法思想跟BM算法很相似,在匹配失敗時(shí)關(guān)注的是文本串中參加匹配的最末位字符的下一位字符,下面是用C#實(shí)現(xiàn)sunday的實(shí)例代碼,有需要的朋友可以參考一下
    2013-08-08

最新評(píng)論

建宁县| 仲巴县| 南部县| 云霄县| 绵阳市| 柳州市| 静海县| 饶平县| 抚顺县| 大悟县| 磐安县| 惠州市| 甘德县| 建德市| 仪陇县| 宜宾市| 济宁市| 云阳县| 灌阳县| 遂昌县| 双江| 涪陵区| 贵州省| 信丰县| 临泉县| 彩票| 黄石市| 巴塘县| 苗栗市| 米脂县| 平利县| 巴彦淖尔市| 怀化市| 石柱| 绥阳县| 中超| 兴化市| 谷城县| 景谷| 五家渠市| 余干县|