开发者社区 问答 正文

jQuery css() 方法设置多个样式属性

$big.css("margin-left", x + "px");
$big.css("margin-top", y + "px");
$big.css("background-position", bigX+" "+bigY);

这种带变量的属性设置该怎么合并成一条语句啊?

展开
收起
小旋风柴进 2016-03-26 11:57:14 1875 分享 版权
1 条回答
写回答
取消 提交回答
  • 跟对象一样

    $big.css({
    
       "margin-left": x + "px",
       "margin-top":y + "px",
       "background-position": bigX+" "+bigY
       })
    2019-07-17 19:16:01
    赞同 展开评论