一則C#簡(jiǎn)潔瀑布流代碼
View頁(yè)面。
@{
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ù)端:
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);
}
- jQuery Masonry瀑布流插件使用詳解
- 異步加載技術(shù)實(shí)現(xiàn)當(dāng)滾動(dòng)條到最底部的瀑布流效果
- Blocksit插件實(shí)現(xiàn)瀑布流數(shù)據(jù)無(wú)限( 異步)加載
- 一個(gè)簡(jiǎn)單的瀑布流效果(主體形式自寫)
- 純js實(shí)現(xiàn)瀑布流展現(xiàn)照片(自動(dòng)適應(yīng)窗口大小)
- jquery簡(jiǎn)單瀑布流實(shí)現(xiàn)原理及ie8下測(cè)試代碼
- Jquery瀑布流插件使用介紹
- ThinkPHP自動(dòng)完成中使用函數(shù)與回調(diào)方法實(shí)例
- thinkphp四種url訪問(wèn)方式詳解
- thinkphp數(shù)據(jù)查詢和遍歷數(shù)組實(shí)例
- thinkphp的URL路由規(guī)則與配置實(shí)例
- thinkPHP實(shí)現(xiàn)瀑布流的方法
相關(guān)文章
C#創(chuàng)建SQLite控制臺(tái)應(yīng)用程序詳解
這篇文章主要為大家詳細(xì)介紹了C#創(chuàng)建SQLite控制臺(tái)應(yīng)用程序,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07c#讀取excel數(shù)據(jù)的兩種方法實(shí)現(xiàn)
這篇文章主要介紹了c#讀取excel數(shù)據(jù)的兩種方法實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12C#中IList<T>與List<T>的區(qū)別深入解析
本篇文章主要是對(duì)C#中IList<T>與List<T>的區(qū)別進(jìn)行了詳細(xì)的分析介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-01-01c#之滾動(dòng)字幕動(dòng)畫窗體的實(shí)現(xiàn)詳解
本篇文章是對(duì)c#中滾動(dòng)字幕動(dòng)畫窗體的實(shí)現(xiàn)方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06