為網格布局圖片打造的超炫 CSS 加載動畫

  今天,我想與大家分享一些專門為網格布局的圖像制作的很酷的 CSS 加載動畫效果。您可以把這些效果用在你的作品集,博客或任何你想要的網頁中。設置很簡單。我們使用了下面這些工具庫來實現這個效果:

  • Normalize.css 來替代傳統的 CSS 復位;
  • ZURB Foundation?創建具有響應式的網格;
  • Masonry?創建一個動態的網格布局;
  • imagesLoaded 檢查是否已加載圖像;
  • Infinite Scroll?加載更多圖片并追加到畫廊。

  現在,讓我們來看看一些實際的代碼,這應該是大家最想知道的!

?

?

效果演示? ? ??源碼下載

?

HTML 代碼

其實 HTML 代碼都是很簡單的,復雜和創意的部分在 CSS。代碼如下:

<div class="row"><div class="large-12 columns main"><ul class="small-block-grid-2 medium-block-grid-3 large-block-grid-3 masonry"><li class="masonry-item"><a target="_blank" href="#"><img src="images/01.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#"><img src="images/02.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#"><img src="images/03.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#"><img src="images/04.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#/"><img src="images/05.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#"><img src="images/06.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#"><img src="images/07.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#"><img src="images/08.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#"><img src="images/09.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#"><img src="images/10.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#"><img src="images/11.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#"><img src="images/12.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#/"><img src="images/13.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#"><img src="images/14.jpg" alt="" /></a></li><li class="masonry-item"><a target="_blank" href="#"><img src="images/15.jpg" alt="" /></a></li></ul><ul class="pagination"><li><a class="next" href="index-02.php">Next Page</a></li></ul><div class="loading"></div></div><!-- End .main -->
</div><!-- End .row -->

CSS 代碼

CSS 部分主要是動畫效果,我們以 tada 效果為例:

@keyframes tada
{0%{-webkit-transform: scale(1);-moz-transform: scale(1);-ms-transform: scale(1);-o-transform: scale(1);transform: scale(1);}10%,20%{-webkit-transform: scale(.8) rotate(-2deg);-moz-transform: scale(.8) rotate(-2deg);-ms-transform: scale(.8) rotate(-2deg);-o-transform: scale(.8) rotate(-2deg);transform: scale(.8) rotate(-2deg);}30%,50%,70%,90%{-webkit-transform: scale(1.04) rotate(2deg);-moz-transform: scale(1.04) rotate(2deg);-ms-transform: scale(1.04) rotate(2deg);-o-transform: scale(1.04) rotate(2deg);transform: scale(1.04) rotate(2deg);}40%,60%,80%{-webkit-transform: scale(1.04) rotate(-2deg);-moz-transform: scale(1.04) rotate(-2deg);-ms-transform: scale(1.04) rotate(-2deg);-o-transform: scale(1.04) rotate(-2deg);transform: scale(1.04) rotate(-2deg);}100%{-webkit-transform: scale(1) rotate(0);-moz-transform: scale(1) rotate(0);-ms-transform: scale(1) rotate(0);-o-transform: scale(1) rotate(0);transform: scale(1) rotate(0);}
}.tada
{-webkit-animation-name: tada;-moz-animation-name: tada;animation-name: tada;
}

jQuery

當圖像被加載進來后,我們給圖像添加上 CSS 效果,然后我們找到并顯示該項目,最后會刷新 Masonry 布局。當用戶滾動頁面的時候,無限滾動插件將裝載更多的圖像并重復前面的步驟。代碼如下:

jQuery(document).ready(function($) {// Replace "tada" with an effect from the "effects.css" file.var effect = 'animate tada';var masonry_selector = '.masonry';var masonry_item_selector = '.masonry-item';// Initialize Masonry.var $masonry = $(masonry_selector).masonry({itemSelector: masonry_item_selector});// Find and hide the items.var $masonry_items = $masonry.find(masonry_item_selector).hide();// Wait for the images to load.$masonry.imagesLoaded()// An image has been loaded..progress(function(instance, image) {// Add the effect.var $image = $(image.img).addClass(effect);// Find and show the item.var $item = $image.parents(masonry_item_selector).show();// Lay out Masonry.$masonry.masonry();});// Load more items.$masonry.infinitescroll({navSelector: '.pagination',nextSelector: '.pagination .next',itemSelector: masonry_item_selector,loading: {finishedMsg: 'No more pages to load.',img: 'images/loader.gif',msgText: 'Loading the next page.',selector: '.loading'}}, function(items, data, url) {var $items = $(items).hide().imagesLoaded().progress(function(instance, image) {var $image = $(image.img).addClass(effect);var $item = $image.parents(masonry_item_selector).addClass('infinite-scroll-item').show();$masonry.masonry('appended', $item);});});});

  

您可能感興趣的相關文章
  • Web 開發中很實用的10個效果【源碼下載】
  • 精心挑選的優秀jQuery Ajax分頁插件和教程
  • 12個讓人驚嘆的的創意的 404 錯誤頁面設計
  • 讓網站動起來!12款優秀的 jQuery 動畫插件
  • 十分驚艷的8個 HTML5 & JavaScript 特效

?

本文鏈接:為網格布局圖片打造的超炫 CSS 加載動畫效果

編譯來源:夢想天空 ◆ 關注前端開發技術 ◆ 分享網頁設計資源

轉載于:https://www.cnblogs.com/lhb25/p/css-loading-effects-grid-layout-images.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/259976.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/259976.shtml
英文地址,請注明出處:http://en.pswp.cn/news/259976.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

HTML多選框滾動條,《HTM單選.doc

《HTM單選1. 下面標記中&#xff0c;( )在標記的位置添加一個回車符。【選擇一項】A. B. C. D. 2. 要實現以下功能&#xff1a;在網頁中插入一個圖片joke11.gif,使用者通過單擊該圖片&#xff0c;連接到joke11.htm上去。下面的HTML代碼&#xff0c;( )是正確的。【選擇一項】A…

python時間處理模塊有哪些_Python模塊之時間處理

time 模塊>>> import time>>> dir(time)[__doc__, __name__, __package__, accept2dyear, altzone, asctime, clock, ctime, daylight, gmtime, localtime, mktime, sleep, strftime,strptime, struct_time, time, timezone, tzname]包含的變量:timezone -- …

wel

歡迎來到mathant.com 這個網站是什么 這個網站是我搭建在阿里云vps上的個人網站。目前的用途是充當個人博客和云存儲&#xff0c;當然它的功能不止如此。我會在以后的日子里完善他&#xff0c;希望他能變得更好。目前我在主機上只搭建了這個個人博客和一個ftp服務器。這個網站采…

php 安裝rabbitmq擴展無報錯版

需要安裝rabbitmq-c&#xff0c;rabbitmq-c是一個用于C語言的&#xff0c;與AMQP server進行交互的client庫。下載了v0.5.2版本(https://github.com/alanxz/rabbitmq-c/releases/download/v0.5.2/rabbitmq-c-0.5.2.tar.gztar xvf rabbitmq-c-0.5.2.tarcd rabbitmq-c-0.5.2autor…

ImageMagick 打水印支持透明度設置

convert 35021021120924162418300.jpg DD.png -geometry 60002048 -compose dissolve -define compose:args50 -composite -quality 95 35021021120924162418300_res.jpg轉載于:https://www.cnblogs.com/mfryf/archive/2013/03/04/2943209.html

spring mvc使用html頁面,使用Spring MVC的純HTML頁面應用程序

在Spring MVC所有的請求經過FrontController - DispatcherServlet的有你需要告訴Spring allowe JSP和HTML都在你的情況例dispatcher-servlet.xml:xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xmlns:p"http://www.springframework.org/schema/p"x…

python win+r時不成功_Win與R(不使用Anaconda的情況下)

配置R的路徑信息&#xff1a;Path&#xff1a;添加R.dll的路徑 如&#xff1a;E:\software\R\R-3.5.1\bin\x64R_HOME:R的安裝路徑 如&#xff1a;E:\software\R\R-3.5.1\binR_USER:R的使用路徑 如&#xff1a;E:\software\R\R-3.5.1\bin\x64pip install rpy2在win下安裝失敗&am…

Devexpress VCL Build v2014 vol 14.1.4 發布

雖然這次沒加什么新東西&#xff0c;但是及時更新支持xe7&#xff0c;還算可以。 Whats New in 14.1.4 (VCL Product Line) New Major Features in 14.1 Whats New in VCL Products 14.1 Feature Highlights To learn about feature highlights in this version, please refer …

一個YII社區學習網站

2019獨角獸企業重金招聘Python工程師標準>>> https://getyii.com/ 轉載于:https://my.oschina.net/u/2552765/blog/803311

一站式 Java Web 框架 firefly-2.0_07發布

Firefly是一個高性能一站式Web框架。 涵蓋了web開發的主要技術棧。 包含Template engine、IOC、MVC framework、HTTP Server、Common tools、Log、Json parser等模塊。 firefly-2.0_07修復了模版壓縮對javascript單行注釋的影響&#xff0c;并新增了自定義錯誤頁面功能。 更新日…

計算機控制學什么,計算機控制技術專業介紹

專業前景需要早了解&#xff0c;計算機控制技術專業學什么&#xff0c;好不好找工作等是學子和家長朋友們十分關心的問題。以下是個人簡歷網整理的計算機控制技術專業介紹、主要課程、培養目標、就業前景&#xff0c;供大家參考。1、計算機控制技術專業簡介計算機控制技術專業&…

【Python】Python 批量轉換PDF到Excel

PDF是面向展示和打印使用的&#xff0c;并未考慮編輯使用&#xff0c;所以缺少了很多編輯屬性且非常難修改PDF里面的數據。當您需要分析或修改PDF文檔數據時&#xff0c;可以將PDF保存為Excel工作簿&#xff0c;實現輕松編輯數據的需求。PDF轉Excel&#xff0c;技術關鍵就是提取…

js showModalDialog參數的使用詳解(轉)

js showModalDialog參數的使用詳解_javascript技巧_腳本之家 http://www.jb51.net/article/45281.htm 本篇文章主要是對js中showModalDialog參數的使用進行了詳細的分析介紹&#xff0c;需要的朋友可以過來參考下&#xff0c;希望對大家有所幫助 基本介紹&#xff1a; showModa…

ad19生成gerber文件_在“AD19”中怎樣將PCB文件轉換為GERBER

四川自貢是歷史悠久的老工業城市&#xff0c;上世紀八、九十年代&#xff0c;自貢的鍋爐、泵業、閥門全國聞名&#xff0c;在近年發展中&#xff0c;電子產業也取得可喜的成績。Altium Designer在設計電子產品中是應用較多的工具&#xff0c;它的版本更新很快&#xff0c;從最早…

讓windows 2003啟動后直接進入桌面

windows 2003啟動后進入桌面需要解決的幾個問題 1、如何去除掉 ctrlaltdel的提示界面 2、如何設置自動登錄的用戶名密碼 3、在異常啟動時會出現關閉事件跟蹤程序 也會導致不能直接進入桌面 往往直接進入桌面是卡在了這個環節 一、去掉ctrlaltdel的提示界面 1、“開始-->運行…

【C】——C項目中的菜單功能(源碼)

1 #include<stdio.h>2 #include<stdlib.h>3 4 int menu() //選擇菜單5 {6 int result;7 printf("**********請選擇&#xff1a;***********\n");8 printf("**********1.插入&#xff1a;***********\n");9 printf(&quo…

a 中調用js的幾種方法

我們常用的在a標簽中有點擊事件&#xff1a;1. a href"javascript:js_method();"這是我們平臺上常用的方法&#xff0c;但是這種方法在傳遞this等參數的時候很容易出問題&#xff0c;而且javascript:協議作為a的href屬性的時候不僅會導致不必要的觸發window.onbefore…

MapReduce實現手機上網日志分析(分區)

一、問題背景 實際業務的需要&#xff0c;比如以移動為例&#xff0c;河南的用戶去了北京上網&#xff0c;那么他的上網信息默認保存在了北京的基站&#xff0c;那么我們想要查詢北京地區的上網日志信息默認也包含了其他地區用戶的在本區的上網信息&#xff0c;否則只能掃描日志…

肺功能曲線圖怎么看_如何看肺功能結果報告單

收藏進澤 2006-05-18 22:34:46常規通氣功能&#xff1a;所有的指標都要在預計值的80&#xff05;以上&#xff0c;一秒率要在70&#xff05;以上(因為低于70&#xff05;就是COPD).FVC低于80&#xff05;&#xff0c;診斷限制性通氣&#xff1b;一秒率低于70&#xff05;&#…

html 模板配置,模板文件配置

模板文件一定要小寫下劃線&#xff0c;如 list_pubu.html你可以給你每一個模板文件增加一個json配置文件,用于描述這個模板文件;配置文件和模板文件名是同名的,只是后綴為 json,如simpleboot3/portal/index.html模板文件的配置文件就是simpleboot3/portal/index.json;一個簡單的…