更改按钮图像onclick,然后单击后返回原始图像

<style>
img.button-send {
background: url(img/agentsprite.png) 0 0;
width:87px;
height:34px;
opacity:0;
}
img.button-send:active {
background: url(img/agentsprite.png) 34 174;
width:87px;
height:34px;
}

</style>
      <button type="submit">
      <img class="button-send" src="img/img_trans.gif" width="1" height="1" />
          </button>


我为此使用了一个精灵,当我单击它时它似乎不会移到该图像位置,有什么办法可以工作吗?按下时,我不会对此字段产生按钮效果。

最佳答案

....................................

您好,现在习惯于background-position图片中的px值

像这样

img.button-send:active {
background: url(img/agentsprite.png) 34px 174px;
}


或者你也可以用这个

img.button-send:active {
    background-position:34px 174px;
    }


px根据您的设计的价值

07-24 09:50
查看更多