実際の画像がダウンロードされるまで、アニメーション画像を使用して読み込みの進行状況を表示できる機能に取り組んでいます。
レコードをループしてリピーターコントロールを使用して表示する画像がたくさんあるページがあります。以下はコード HTML-CSS の例です
<asp:Repeater ID="rpt4x42" runat="server" EnableViewState="False">
<ItemTemplate>
<asp:HyperLink ID="hylTopFour2" style=" text-decoration:none;" runat="server"
NavigateUrl='<%# getURL(Eval("ArticleID")) %>' BorderWidth="0px" meta:resourcekey="hylTopFour2Resource1">
<div id="articleContainer2" class="articleContainer" >
<div id="ArticleImgHP-container" >
<asp:Image ID="imgTopFourImg2" runat="server" width="170px" height="112px" CssClass="ArticleImgHP"
border="0" ImageUrl='<%# getImagePath(Eval("ArticleThumNailImage")) %>' />
</div>
<div class="Details4x4">
<div class="Title4x4" >
<asp:Label ID="lblTopFourTitle" runat="server" Text='<%# getTitle(Eval("ArticleTitle")) %>'></asp:Label>
</div>
<div class="hLine4x4"></div>
<div class="dateWrapper4x4">
<div class="Date4x4">
<asp:Label ID="lblTopFourDate" runat="server"
Text='<%# FormatDate(Eval("[ArticlePublishDate]")) %>'></asp:Label>
</div>
</div>
</div>
</div>
</asp:HyperLink>
</ItemTemplate>
</asp:Repeater>
</div>
CSS
img.ArticleImgHP {
/* Set the width and height to the size of its container */
width : 100%;
height : 100%;
visibility : hidden;
}
div.ArticleImgHP-container {
width : 170px;
height : 112px;
background-image: url('../images/loading-circle.gif');
background-position: center center;
background-repeat: no-repeat;
}
jQuery
$(document).ready(function () {
// $("img #MainContent_rpt4x42_imgTopFourImg2_1").bind("load", function () { $(this).show(); });
$("img.ArticleImgHP").bind("load", function () { $(this).css("visibility", "visible"); });
});
実際の画像を div タグ内にラップしました。実際の画像がダウンロードされるまで、この div タグの背景画像を表示したいと思います。動作させることができません。この点で助けていただければ幸いです。
私は同じことをjsFiddleで実行しようとしていますが、動作していませんhttp://jsfiddle.net/t5d39/13/