【问题标题】:jquery rotate rectangle around x y axisjquery围绕x y轴旋转矩形
【发布时间】:2014-07-24 03:54:30
【问题描述】:

我有一个矩形 div 放置在左上角 200 像素宽和 100% 高。我想在这个 div 中放置一个图像,但是图像是横向的(w:1024 h:200)我认为没有问题只是旋转它,我可以这样做,但我无法定位它。所以需要一些帮助来定位左上角!

$('.header_rotate').css({                              
transform: 'rotate('+ -90 +'deg)',                                                                                    
backgroundColor: 'green',
height: '100%',
width: '200'                      
})

<div class="header">
  <div class="header_rotate">
      <img id="logo" src="img/Logo_Design_2048x410.png" />
  </div>
 </div>

JsFiddel

【问题讨论】:

    标签: javascript jquery css rotation transform


    【解决方案1】:

    使用 transform:rotate(90deg) 您可以添加 translateX 和 translateY 以使其定位正确。

    $('.header_rotate').css({
    
      transform: 'translateX(-130px) translateY(200px) rotate(90deg)',
      backgroundColor: 'green',
      height: '200',
      width: '600',
    });
    

    这是小提琴:

    http://jsfiddle.net/dRvy8/2/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-09
      • 1970-01-01
      • 2021-07-12
      • 2022-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多