CSS翻转小效果
CSS3翻转显示另外一张图:
1、backface-visibility:hidden;背面不可见
2、transform:rotate();旋转
(可以把图片换成本地图片看一下效果)
<!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>