jQuery CSS在不改变翻译的情况下设置子元素的比例

jQuery CSS set scale of child element without altering translation

本文关键字:设置 元素 情况下 jQuery 改变 翻译 CSS      更新时间:2023-09-26

如何阻止.css("-webkit-transform", ...删除已存在的元素转换?

HTML&CSS:

<div class="parent">
    <div class="child" style="-webkit-transform:translate(10px,60px) scale(0.6);"></div>
    <div class="child" style="-webkit-transform:translate(80px,12px) scale(0.4);"></div>
</div>

jQuery:

$(".parent").children(".child").css("-webkit-transform", "scale(0.9)");

JSFIDDLE

只需连接值:

$(".parent").children(".child").css("-webkit-transform", function(i, value) {
    return value + " scale(0.9)";
});

演示:http://jsfiddle.net/qET8N/1/