利用CSS,可在用户将光标悬停在一个连接或按钮上时为连接或按键创建另一种样式(称为翻转)还可在用户单击它时创建第三种样式。
<html> <head> <title>TODO supply a title</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style type="text/css"> a.button { height: 36px; background-image: url("button-sprite.jpg"); text-indent: -9999px; display: inline-block;} a#add-to-basket { 174px; background-position: 0px 0px;} a#framing-options { 210px; background-position: -175px 0px;} a#add-to-basket:hover { background-position: 0px -40px;} a#framing-options:hover { background-position: -175px -40px;} a#add-to-basket:active { background-position: 0px -80px;} a#framing-options:active { background-position: -175px -80px;} </style> </head> <body> <a class="button" id="add-to-basket">Add to basket</a> <a class="button" id="framing-options">Framing options</a> </body> </html>