嗨,我看到了使用jquery调整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;
}
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<div class="resize">
resize helper
</div>
<div class='resize-plus'></div>
<div class='resize-minus'></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>
现在我有div的类resize-plus,resize-minus。如果我们点击resize-plus我需要增加svg的大小,如果resize-minus我需要减小svg的大小。那就是resize功能需要修改在这两个div中 那么该怎么做呢?以及如何设置条件,例如图像大小是否增加小于和小于调整大小。谢谢你 。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句