代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .father { width: 1366px; height: 600px; background: url(./images/bg.jpg); margin: 0 auto; overflow: hidden; } .son1 { float: left; width: 50%; height: 600px; background: url(./images/fm.jpg); transition: all 1s; } .son2 { float: left; width: 50%; height: 600px; background: url(./images/fm.jpg) no-repeat right 0; transition: all 1s; } .father:hover .son1 { transform: translate(-100%); } .father:hover .son2 { transform: translate(100%); } </style> </head> <body> <div class="father"> <div class="son1"></div> <div class="son2"></div> </div> </body> </html>
鼠标移动上去之后,有一个开门的效果。