简体   繁体   English

x,y,左,右与CSS的区别

[英]Difference between x, y, left, right with CSS

I have something that looks like this, which doesn't apply the x or y transform but does apply rotation. 我有一个看起来像这样的东西,它不应用x或y变换,但是应用旋转。

$('<div/>').css(
   "-webkit-transform": "rotate(20deg)"
   x: 10
   y: 10
)

This applies the x and y but not the rotation: 这将应用xy但不会应用旋转:

$('<div/>').css(
  "-webkit-transform": "rotate(20deg)"
  x: 10
  y: 10
)

If I do it with left and right it works 如果我left right都可以

$('<div/>').css(
   "-webkit-transform": "rotate(20deg)"
   left: 10
   right: 10
)

PS: I'm using coffeescript PS:我正在使用coffeescript

If you're asking why left and right work but x and y don't, it's because you're using .css() which is ultimately setting CSS and there is no x or y CSS properties. 如果您要问为什么left rightxy对不对,那是因为您使用的.css()最终会设置CSS,并且没有xy CSS属性。

You're probably looking for translate() : 您可能正在寻找translate()

-webkit-transform: translate(50px,100px);

You can add css object as below, 您可以如下添加css对象,

$('<div/>').css({
   "-webkit-transform": "rotate(20deg)"
   x: 10
   y: 10
});

there is one jQuery plugin that do css animation. 有一个做CSS动画的jQuery插件。

Plugin Link

x , y are not valid CSS attributes. xy不是有效的CSS属性。 You should use left , top instead. 您应该改用lefttop

Check this jsFiddle 检查这个jsFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 y中的x与y [x]之间的区别 - Difference between `x in y` vs `y[x]` $('x &gt; y')、$('y'、'x') 和 $('x y') 有什么区别? - What's the difference between $('x > y'), $('y', 'x'), and $('x y')? 在JavaScript中,typeof x ==&#39;y&#39;和typeof x ===&#39;y&#39;之间有什么区别吗? - In JavaScript, is there any difference between typeof x == 'y' and typeof x === 'y'? javascript可以告诉左右键之间的区别吗? - Can javascript tell the difference between left and right shift key? 生成x和y之间的“随机”数,其差至少为100 - Generate 'random' numbers between x and y with a difference of at least 100 “function xy()”和“xy = function()”之间有什么区别? - What's the difference between “function x.y()” and “x.y = function ()”? for(var x in array)和for(var x = 0,y = array.length; x之间的性能差异 - Performance's difference between for (var x in array) and for (var x=0, y= array.length; x<y; x++) CSS 从左到右淡入淡出 - CSS fade left to right CSS 为 slider 从左到右? - CSS for slider left to right? 对项目数组(具有X / Y属性)进行排序,以便从左到右,从上到下排序 - Sort an array of items (with X/Y properties) so they are ordered left to right, top to bottom
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM