Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Jquery调整Svg图像大小_Javascript_Jquery_Svg - Fatal编程技术网

Javascript 使用Jquery调整Svg图像大小

Javascript 使用Jquery调整Svg图像大小,javascript,jquery,svg,Javascript,Jquery,Svg,我正在编写一个PHP脚本,其中包含一个包含SVG的页面。我想做的是使用Jquery调整大小功能。我曾在一个div上尝试过这个方法,效果很好,但是当我想用它来调整SVG中图像的大小时,它就不起作用了。 代码如下: 多尤德 试试这个 在div上包装到图像 html css 谢谢你的提示。我能够将svg对象包装在一个div中,然后使用ResizeUI事件大小来设置对象上的CSS HTML 您可以尝试将SVG放入一些DIV中,将SVG的宽度和高度设置为“100%”,并使DIV的大小可调整。将此设置为S

我正在编写一个PHP脚本,其中包含一个包含SVG的页面。我想做的是使用Jquery调整大小功能。我曾在一个div上尝试过这个方法,效果很好,但是当我想用它来调整SVG中图像的大小时,它就不起作用了。 代码如下:

多尤德 试试这个

在div上包装到图像

html

css


谢谢你的提示。我能够将svg对象包装在一个div中,然后使用ResizeUI事件大小来设置对象上的CSS

HTML


您可以尝试将SVG放入一些DIV中,将SVG的宽度和高度设置为“100%”,并使DIV的大小可调整。将此设置为SVG中的多个图像如何?是否可以将此设置为可能?请您也添加旋转选项。@Felix我无法添加旋转仅使用JqueryUI。但我找到了,这是。我认为这并不完美。您必须计算度数和变换位置。
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="800" height="420" id="svg">
<image height="120" width="120" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://designpieces.com/wp-content/uploads/2013/04/chrome.png" ></image></svg>
$('.resize').resizable({
    ghost: true
            });
            $('image').resizable({
    ghost: true
            });
<div class="resize">
resize helper
</div>


<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="800" height="420" id="svg">
    <image height="120" width="120" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://designpieces.com/wp-content/uploads/2013/04/chrome.png" ></image>
</svg>
$('.resize').resizable({
    ghost: true,
    resize: function( event, ui ) {
        var width = ui.size.width;
      var height = ui.size.height;
      $('image').attr('width',width);
      $('image').attr('height',height);
    }
            });

var position = $('svg').position();
$('.resize').css('top',position.top);
$('.resize').css('left',position.left);
.resize{
  height: 120px;
  width: 120px;
  position:absolute;
  z-index:0;
}
  <div id="divVirtualKeyboard" style="display: none; position: absolute; top: 200px; left: 100px">
    <div>
      <object id="canvasKeyboard" data="static/EmulatorKeyboard.svg" type="image/svg+xml" width="376" height="214" style="pointer-events:none;"></object>
    </div>
  </div>
  div.resizable(
    {
      aspectRatio: 376 / 214,
      resize: function (event, ui) {
        div.find('object').css('width', ui.size.width)
        div.find('object').css('height', ui.size.height)
      }
    });