发现一款很酷的jquery 相片墙翻牌效果

可用于 企业网站中的 赞助商、 合作伙伴、 公司产品、 招聘计划等等模块

主要运用的技术有 php +CSS + Jquery插件 flip http://lab.smashup.it/flip/

实现步骤可以大致这样来讲

我们可以看到某个翻牌的div 的源码如下

Java代码 发现一款很酷的jquery 相片墙翻牌效果
  1. <spanstyle="font-size:14px;"><divtitle="Clicktoflip"class="sponsor">
  2. <divclass="sponsorFlip">
  3. <imgalt="Moreaboutgoogle"src="img/sponsors/google.png">
  4. </div>
  5. <divclass="sponsorData">
  6. <divclass="sponsorDescription">
  7. Thecompanythatredefinedwebsearch.
  8. </div>
  9. <divclass="sponsorURL">
  10. <ahref="http://www.google.com/">http://www.google.com/</a>
  11. </div>
  12. </div>
  13. </div></span>

Step 1 我们会首先建立一个 $Sponsor的数组 数组内 含有以下信息 包括logo 网址等内容

Php代码 发现一款很酷的jquery 相片墙翻牌效果
  1. <spanstyle="font-size:14px;">//Eachsponsorisanelementofthe$sponsorsarray:
  2. $sponsors=array(
  3. array('facebook','Thebiggestsocial..','http://www.facebook.com/'),
  4. array('adobe','Theleadingsoftwarede..','http://www.adobe.com/'),
  5. array('microsoft','Oneofthetopsoftwarec..','http://www.microsoft.com/'),
  6. array('sony','Aglobalmultibillionelectronics..','http://www.sony.com/'),
  7. array('dell','Oneofthebiggestcomputerdevelo..','http://www.dell.com/'),
  8. array('ebay','Thebiggestonlineauctionand..','http://www.ebay.com/'),
  9. array('digg','Oneofthemostpopularweb2.0..','http://www.digg.com/'),
  10. array('google','Thecompanythatredefinedw..','http://www.google.com/'),
  11. array('ea','Thebiggestcomputergamemanufacturer.','http://www.ea.com/'),
  12. array('mysql','Themostpopularopensourcedat..','http://www.mysql.com/'),
  13. array('hp','Oneofthebiggestcomputermanufacturers.','http://www.hp.com/'),
  14. array('yahoo','Themostpopularnetworkofso..','http://www.yahoo.com/'),
  15. array('cisco','Thebiggestnetworkingandco..','http://www.cisco.com/'),
  16. array('vimeo','Apopularvideo-centricsocialn..','http://www.vimeo.com/'),
  17. array('canon','Imagingandopticaltechnologyma..','http://www.canon.com/')
  18. );
  19. //Randomizingtheorderofsponsors:
  20. shuffle($sponsors);</span>

Step2 然后我们会通过遍历整个数组在页面中展示出来

Php代码 发现一款很酷的jquery 相片墙翻牌效果
  1. <spanstyle="font-size:14px;">//Loopingthroughthearray:
  2. foreach($sponsorsas$company)
  3. {
  4. echo'
  5. <divclass="sponsor"title="Clicktoflip">
  6. <divclass="sponsorFlip">
  7. <imgsrc="img/sponsors/'.$company[0].'.png"alt="Moreabout'.$company[0].'"/>
  8. </div>
  9. <divclass="sponsorData">
  10. <divclass="sponsorDescription">
  11. '.$company[1].'
  12. </div>
  13. <divclass="sponsorURL">
  14. <ahref="'.$company[2].'">'.$company[2].'</a>
  15. </div>
  16. </div>
  17. </div>
  18. ';
  19. }</span>

Step 3用到的css 样式如下

Html代码 发现一款很酷的jquery 相片墙翻牌效果
  1. <spanstyle="font-size:14px;">body{
  2. /*Settingdefaulttextcolor,backgroundandafontstack*/
  3. font-size:0.825em;
  4. color:#666;
  5. background-color:#fff;
  6. font-family:Arial,Helvetica,sans-serif;
  7. }
  8. .sponsorListHolder{
  9. margin-bottom:30px;
  10. }
  11. .sponsor{
  12. width:180px;
  13. height:180px;
  14. float:left;
  15. margin:4px;
  16. /*Givingthesponsordivarelativepositioning:*/
  17. position:relative;
  18. cursor:pointer;
  19. }
  20. .sponsorFlip{
  21. /*Thesponsordivwillbepositionedabsolutelywithrespect
  22. toitsparent.sponsordivandfillitinentirely*/
  23. position:absolute;
  24. left:0;
  25. top:0;
  26. width:100%;
  27. height:100%;
  28. border:1pxsolid#ddd;
  29. background:url("img/background.jpg")no-repeatcentercenter#f9f9f9;
  30. }
  31. .sponsorFlip:hover{
  32. border:1pxsolid#999;
  33. /*CSS3insetshadow:*/
  34. -moz-box-shadow:0030px#999inset;
  35. -webkit-box-shadow:0030px#999inset;
  36. box-shadow:0030px#999inset;
  37. }
  38. /////////////////////////////////////////////////////////////////
  39. .sponsorFlipimg{
  40. /*Centeringthelogoimageinthemiddleofthe.sponsorFlipdiv*/
  41. position:absolute;
  42. top:50%;
  43. left:50%;
  44. margin:-70px00-70px;
  45. }
  46. .sponsorData{
  47. /*Hidingthe.sponsorDatadiv*/
  48. display:none;
  49. }
  50. .sponsorDescription{
  51. font-size:11px;
  52. padding:50px10px20px20px;
  53. font-style:italic;
  54. }
  55. .sponsorURL{
  56. font-size:10px;
  57. font-weight:bold;
  58. padding-left:20px;
  59. }
  60. .clear{
  61. /*Thisclassclearsthefloats*/
  62. clear:both;
  63. }</span>

Step4 主要运用的jquey 方法如下

Html代码 发现一款很酷的jquery 相片墙翻牌效果
  1. <spanstyle="font-size:14px;">$(document).ready(function(){
  2. /*ThefollowingcodeisexecutedoncetheDOMisloaded*/
  3. $('.sponsorFlip').bind("click",function(){
  4. //$(this)pointtotheclicked.sponsorFlipelement(cachingitinelemforspeed):
  5. varelem=$(this);
  6. //data('flipped')isaflagwesetwhenwefliptheelement:
  7. if(elem.data('flipped'))
  8. {
  9. //Iftheelementhasalreadybeenflipped,usetherevertFlipmethod
  10. //definedbytheplug-intoreverttothedefaultstateautomatically:
  11. elem.revertFlip();
  12. //Unsettingtheflag:
  13. elem.data('flipped',false)
  14. }
  15. else
  16. {
  17. //Usingtheflipmethoddefinedbytheplugin:
  18. elem.flip({
  19. direction:'lr',
  20. speed:350,
  21. onBefore:function(){
  22. //Insertthecontentsofthe.sponsorDatadiv(hidden
  23. //fromviewwithdisplay:none)intotheclicked
  24. //.sponsorFlipdivbeforetheflippinganimationstarts:
  25. elem.html(elem.siblings('.sponsorData').html());
  26. }
  27. });
  28. //Settingtheflag:
  29. elem.data('flipped',true);
  30. }
  31. });
  32. });</span>

相关文章:

  • 2022-01-07
  • 2021-05-04
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2021-11-15
猜你喜欢
  • 2022-02-19
  • 2021-10-20
  • 2021-09-19
  • 2021-12-16
  • 2021-04-12
相关资源
相似解决方案