HTML5¼¼Êõ

´¸×ÓÉ̳ÇÊ×Ò³bannerͼÊó±ê¸úËæ¼°ÊÓ¾õ²îЧ¹û - tian0o0

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-11-19 12:08 ÎÒÒªÆÀÂÛ( )

ÎÒ·¢ÏÖÏÖÔںܶàÍøÕ¾¶¼Ê¹ÓÃÁËÕâÖÖЧ¹û£¬±ÈÈç˵´¸×Ó¹ÙÍø¡¢elementui¹ÙÍø¡¢Ãëζ¿ÎÌõȣ¬²»µ¥µ¥ÓÐÊó±ê¸úËæµÄЧ¹û£¬Ëæ×ÅÊó±êµÄÒƶ¯»¹ÓÐÊÓ¾õ²îµÄЧ¹û£¬¿´ÆðÀ´ºÜ¸ß´óÉϵļ¼Êõ£¬ÆäʵʵÏÖÆðÀ´ºÜ¼òµ¥£¬Ö÷ÒªÀûÓÃcss3µÄtransform-styleºÍpersperctiveÊôÐÔ¡£ ·Ï»°²»¶à˵ֱ

ÎÒ·¢ÏÖÏÖÔںܶàÍøÕ¾¶¼Ê¹ÓÃÁËÕâÖÖЧ¹û£¬±ÈÈç˵´¸×Ó¹ÙÍø¡¢elementui¹ÙÍø¡¢Ãëζ¿ÎÌõȣ¬²»µ¥µ¥ÓÐÊó±ê¸úËæµÄЧ¹û£¬Ëæ×ÅÊó±êµÄÒƶ¯»¹ÓÐÊÓ¾õ²îµÄЧ¹û£¬¿´ÆðÀ´ºÜ¸ß´óÉϵļ¼Êõ£¬ÆäʵʵÏÖÆðÀ´ºÜ¼òµ¥£¬Ö÷ÒªÀûÓÃcss3µÄtransform-styleºÍpersperctiveÊôÐÔ¡£

·Ï»°²»¶à˵ֱ½ÓÉÏ´úÂ룺

html£º

<div> <div> <span></span> <span>ÒÔ°ÁÂýÓëÆ«Ö´<br/>»Ø¾´°ÁÂýÓëÆ«¼û</span> </div> </div>

css£º

¹Ø¼üÉèÖãº

   1¡¢ÎªÍâ²ãÈÝÆ÷ÉèÖÃperspectiveÊôÐÔ£¬Õâ¸öÊôÐÔÖµ¿ÉÒÔ×Ô¶¨Òå¿ÉÒÔÊÇÊýÖµ¡¢top/bottomµÈ

2¡¢°ÑÄãÏëÒªÉèÖÃΪÊÓ¾õ²îµÄÔªËØÉèÖÃΪ¾ø¶Ô¶¨Î»£¬²¢ÇÒÌí¼Ótransform£ºtanslateZ£¨deg£©ÊôÐÔ

* { font-family: "Microsoft YaHei"; transition: all .3s; -webkit-transition: all .3s; transition-timing-function: linear; -webkit-transition-timing-function: linear; } .perspective { perspective: 800px; } .preserve3d { position: relative; width: 600px; height: 300px; margin: 100px auto; background: url("http://static.smartisanos.cn/index/img/store/home/banner-3d-item-1-box-1_61bdc2f4f9.png") center no-repeat; background-size: 100% 100%; border-radius: 10px; transform-style: preserve-3d; } .preserve3d_img { position: absolute; width: 100%; height: 100%; bottom: 11px; left: 0; background: url("http://static.smartisanos.cn/index/img/store/home/banner-3d-item-1-box-3_8fa7866d59.png") center no-repeat; background-size: 95% 100%; -webkit-transform: translateZ(60px); } .preserve3d_text { position: absolute; top: 20%; right: 10%; font-size: 30px; color: #fff; text-align: right; font-weight: lighter; -webkit-transform: translateZ(40px); }

js£º

$('.preserve3d').on('mouseenter', function() { var thisPX = $(this).offset().left; var thisPY = $(this).offset().top; var boxWidth = $(this).outerWidth(); var boxHeight = $(this).outerHeight(); $(this).addClass("smart_3d"); }) .on('mousemove', function(event) { var mouseX = event.pageX - thisPX; var mouseY = event.pageY - thisPY; var X = mouseX - boxWidth/2; var Y = boxHeight/2 - mouseY; $(this).css({ "-webkit-transform": "rotateY(" + X / 50 + "deg) " + "rotateX(" + Y / 50 + "deg)" }); }) .on('mouseleave', function() { $(this).removeClass("smart3d"); $(this).css({ "-webkit-transform": "rotateY(0deg) rotateX(0deg)" }) })

ok,¾ÍÊÇÕâô¼òµ¥~»¹¿ÉÒÔÖ±½Ó×ö³ÉjQuery²å¼þ£¬¾ßÌå²Î¿¼£º https://github.com/tian0o0/html5/tree/master/smart_banner

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • ΢ÐÅ·þÎñºÅ¿ª·¢-É̳Ç΢ÐŵǼ - ÇàÇð

    ΢ÐÅ·þÎñºÅ¿ª·¢-É̳Ç΢ÐŵǼ - ÇàÇð

    2017-09-30 10:00

  • BootstrapÄâ̬¿ò+Ö§¸¶±¦Ê×Ò³ - ITandYT

    BootstrapÄâ̬¿ò+Ö§¸¶±¦Ê×Ò³ - ITandYT

    2017-06-14 12:00

  • ʹÓÃjsÖÆ×÷Ò»°ãÍøÕ¾Ê×ҳͼƬÂÖ²¥Ð§¹û - ÆïÖíÇôúÂë

    ʹÓÃjsÖÆ×÷Ò»°ãÍøÕ¾Ê×ҳͼƬÂÖ²¥Ð§¹û - ÆïÖíÇôúÂë

    2016-08-30 16:00

  • Ç°¶Ë¿ª·¢--Ê×Ò³ÓÅ»¯ - ¿ÝήµÄº£·ç

    Ç°¶Ë¿ª·¢--Ê×Ò³ÓÅ»¯ - ¿ÝήµÄº£·ç

    2016-07-14 17:00

ÍøÓѵãÆÀ
¡