<!DOCTYPE html> <html > <head> <title>test</title> <meta http-equiv="content-type" content="text/html" charset="utf-8"> <meta name="author" content="xuyunfei"> <meta name="description" content="隨便作作測試"> <meta name="keywords" content="test,html"> <title>隨便作作</title> <style> *{ margin: 0; padding: 0; box-sizing: border-box; } .container, .one, .two{ width: 100px; height: 100px; } .container{ position: relative; transition: 1s; transform-style: preserve-3d; } .container:hover { transform: rotateY(180deg); } .one{ position: absolute; top: 0; background: red; transform: rotateY(180deg);backface-visibility: hidden;}/*兩個元素的位置一致,把背面隱藏起來,背面的元素翻轉過來*/ .two{ position: absolute; top: 0; background: yellow;backface-visibility: hidden;} </style> </head> <body> <div class="par"> <div class="container"> <div class="one hide">隱藏在背後的元素</div> <div class="two show">初始顯示在前面的元素</div> </div> </div> <script type="text/javascript"> </script> </body> </html>