最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Set transform origin property X and Y coordinates - Stack Overflow

programmeradmin1浏览0评论

Set transform origin property X and Y coordinates struggling to set transform origin property from javascript for both axis.

so from javascript: object.style.transformOrigin = valueX valueY;

Unfortunately, it doesnt work... if i set 2 values it doesnt work.. if i set only 1 value, the valueX is changed only.

What i have done:

newClasses.style.transformOrigin = scaleOrigPoint + "px"; // sets only for valueX
newClasses.style.transformOrigin = (scaleOrigPoint + "px") + (scaleOrigPointY + "px"); // sets only for valueY
newClasses.style.transformOrigin = (scaleOrigPoint + "px") , (scaleOrigPointY + "px"); // doesnt set anything + ERROR
newClasses.style.transformOrigin = (scaleOrigPoint + "px") (scaleOrigPointY + "px"); // doesnt set anything + ERROR
newClasses.style.transformOrigin = [scaleOrigPoint]px; // doesnt set anything + ERROR

And many many other ways... Somethimes it changes the valueY only...

Question:

Is there a way to set bot valueX and valueY for transform origin property using javascript only?

Set transform origin property X and Y coordinates struggling to set transform origin property from javascript for both axis.

so from javascript: object.style.transformOrigin = valueX valueY;

Unfortunately, it doesnt work... if i set 2 values it doesnt work.. if i set only 1 value, the valueX is changed only.

What i have done:

newClasses.style.transformOrigin = scaleOrigPoint + "px"; // sets only for valueX
newClasses.style.transformOrigin = (scaleOrigPoint + "px") + (scaleOrigPointY + "px"); // sets only for valueY
newClasses.style.transformOrigin = (scaleOrigPoint + "px") , (scaleOrigPointY + "px"); // doesnt set anything + ERROR
newClasses.style.transformOrigin = (scaleOrigPoint + "px") (scaleOrigPointY + "px"); // doesnt set anything + ERROR
newClasses.style.transformOrigin = [scaleOrigPoint]px; // doesnt set anything + ERROR

And many many other ways... Somethimes it changes the valueY only...

Question:

Is there a way to set bot valueX and valueY for transform origin property using javascript only?

Share Improve this question edited May 23, 2017 at 12:15 CommunityBot 11 silver badge asked Jan 7, 2016 at 13:02 OzZieOzZie 5239 silver badges21 bronze badges 1
  • Style properties set in JavaScript should be strings, as if written in a CSS stylesheet after the <property>:. – maxime.bochon Commented Jan 7, 2016 at 13:07
Add a ment  | 

1 Answer 1

Reset to default 11

Have you tried putting a space between them?

newClasses.style.transformOrigin = scaleOrigPoint + "px " + scaleOrigPointY + "px";
发布评论

评论列表(0)

  1. 暂无评论