滑动门的解决方案
最好的结果是利用父子盒子来解决这个问题。代码实例如下:
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Document</title> | |
| <style> | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| } | |
| div { | |
| height: 33px; | |
| background-image: url(images/bg.png); | |
| background-repeat: no-repeat; | |
| float: left; | |
| } | |
| .left { | |
| width: 20px; | |
| background-position: left -144px; | |
| padding-left: 20px; | |
| } | |
| .right { | |
| background-position: right -144px; | |
| color: white; | |
| padding-right: 20px; | |
| line-height: 33px; | |
| } | |
| .left:hover { | |
| background-position: left -193px; | |
| } | |
| .left:hover .right { | |
| background-position: right -193px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="left"> | |
| <div class="right">abcd</div> | |
| </div> | |
| </body> | |
| </html> |
一直在努力小菜鸟!

浙公网安备 33010602011771号