CSS3翻轉顯示另一張圖:css
一、backface-visibility:hidden;背面不可見html
二、transform:rotate();旋轉spa
(能夠把圖片換成本地圖片看一下效果)code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> * { margin: 0; padding: 0; } .box { width: 560px; height: 300px; position: relative; margin: 100px auto; } .front { width: 100%; height: 100%; position: absolute; top: 0; left: 0; } .back { position: absolute; top: 0; left: 0; } img { transition: all 1s ease 0s; backface-visibility: hidden;/*背面不可見*/ } .back img { transform: rotateX(180deg);/*背面的圖先天翻轉180deg*/ } .box:hover .front img{ transform: rotateX(180deg); } .box:hover .back img { transform: rotateX(360deg); } </style> </head> <body> <div class="box"> <div class="front"> <img src="dog/0.jpg" alt=""> </div> <div class="back"> <img src="dog/1.jpg" alt=""> </div> </div> </body> </html>