【问题标题】:Using Transform Calc rule in jquery在 jquery 中使用 Transform Calc 规则
【发布时间】:2022-01-13 20:02:38
【问题描述】:

不知道如何解释我想要实现的目标,但想知道我是否可以在 jquery 中将 calc() 规则与 transform:rotate() 一起使用。

var degree;
    $(".Input").keyup(function(){
        degree = $(".Input").val()
    $(".Line").css({ 'transform': 'rotate('calc( -180deg + degree + deg)')'});

我的最终目标是每次有人在输入字段中输入数字时将旋转偏移 -180。

【问题讨论】:

  • 如果您想使用 calc,请注意确保 calc 中的 + 号前后有一个空格,并且 -180deg 和 deg 以字符串形式给出。

标签: jquery css rotation transform calc


【解决方案1】:

弄清楚没有必要使用 calc,下面是我需要做的来实现偏移旋转。在它进入旋转 .css 之前几乎要进行数学运算

var degree;
$(".Input").keyup(function(e){
    degree = $(".Input").val() - 180;
$(".Line").css({ 'transform': 'rotate(' + degree + 'deg)'});

【讨论】:

    猜你喜欢
    • 2017-02-09
    • 2014-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-13
    • 1970-01-01
    • 2011-09-01
    • 1970-01-01
    相关资源
    最近更新 更多