一、:hover
<div class="outdiv"> <div class="indiv"></div> </div>
.outdiv { width: 100px; height: 100px; background-color: red; perspective: 400px; } .indiv { width: 100px; height: 100px; background-color: green; transition: all 1s linear; transform-origin: left center; } .outdiv:hover .indiv { transform: rotateY(-180deg); }
二、zoom和transform: scale()区别
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style type="text/css"> .div1 { width: 300px; height: 300px; background: red; zoom: 0.5;/*实际元素的宽高会发生变化*/ } .div2 { width: 300px; height: 300px; background: green; transform: scale(0.5);/*实际元素的宽高不会发生变化*/ } </style> </head> <body> <div class="div1"></div> <div class="div2"></div> </body> </html>