开发者社区> 问答> 正文

怎样让一个图片的background-position横坐标加一个值?

雪碧图x=0 时是点击前的样式, x=100px 时是点击后的样式,
点击前

img1
background: url("../images/images.png") no-repeat scroll 0 -94px;
img2

background: url("../images/images.png") no-repeat scroll 0 -188px;

img3

background: url("../images/images.png") no-repeat scroll 0 -282px;

点击后

img1, img2,img3分别是

background: url("../images/images2.png") no-repeat scroll 100px -94px;

background: url("../images/images.png") no-repeat scroll 100px -188px;

background: url("../images/images.png") no-repeat scroll 100px -282px;

如何编写代码?最好是jquery不是原生的

展开
收起
杨冬芳 2016-06-07 15:32:07 1798 0
1 条回答
写回答
取消 提交回答
  • IT从业
    $('xxx').css('background-position-x', '100px');

    screenshot

    2019-07-17 19:30:20
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载