HTML
CSS
JavaScript
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IT书包</title>
</head>
<body>

<div class="demo_box translate_1">鼠标经过向右移动100像素</div>
<div class="demo_box translate_2">鼠标经过向相反方向移动100像素</div>

</body>
</html>
CSS
.code-preview {
    height: 300px;
    position: relative;
}
.demo_box {
    border: 1px solid #3DA5DC;
    background: #a4dcf9;
    height: 100px;
    width: 200px;
    text-align: center;
    color: #fff;
}
.translate_1{
    -webkit-transition:1s ease all;
    -moz-transition:1s ease all;
    position:absolute;
    left:250px;
    top:10px;
    background:#4d6ea6;
}
.translate_1:hover{
    -webkit-transform:translate(100px);
    -moz-transform:translate(100px);
}
.translate_2{
    -webkit-transition:1s ease all;
    -moz-transition:1s ease all;
    position:absolute;
    left:250px;
    top:150px;
    background:#b9f9cb;
    color:#000;
}
.translate_2:hover{
    -webkit-transform:translate(-100px);
    -moz-transform:translate(-100px);
}
JavaScript