<head> <meta charset="UTF-8"> <title>Title</title> <style> /*translate 的50%是相对于自己的 子元素的百分比高度是根据父元素的高度来确定的, 所以只要设置了父元素的高度,子元素的高度百分比才会有用。 但是(之前没想那么多) transform:translate(100%) 是根据自己走的 */ div{ width: 300px; height: 300px; background-color: grey; } div:hover{ transform: translateX(50%); transition: all 2s; } </style> </head> <body> <div></div> </body>