怎么用translateX让列表内<li>在鼠标经过时右移,鼠标离开时还原?

试了一下用js指定li为a然后再在css里写样式,但是动不起来orz

不用js,用css设置translateX就可以了,如果想要有动效就加个transition时间,写了个demo,参考下:

<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title></title>
	<style type="text/css">
		li{
			width: 100px;
			height: 30px;
			line-height: 30px;
			font-size: 16px;
			cursor: pointer;
			margin-bottom: 10px;
			background: lightblue;
			transition: 0.3s ease;
		}
		li:hover{
			transform: translateX(10px);
		}
	</style>
</head>
<body>
	<div class="box">
		<ul>
			<li>111</li>
			<li>222</li>
			<li>333</li>
		</ul>   
	</div>
</body>
</html>