Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize SVG in DIV and don't preserve aspect ratio

How to resize SVG image in DIV by jQuery UI ? I want to resize DIV and don't preserve aspect ratio of SVG image in this DIV.

jsFiddle example

HTML

   <div style="width: 100px; height:100px; border: 1px solid black;">
      <svg style="width:100%; height:100%; " version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="340.156px" height="340.152px" viewBox="0 0 340.156 340.152" enable-background="new 0 0 340.156 340.152" xml:space="preserve">
          <path fill="#2121ed" fill-opacity="1" stroke="#000000" stroke-width="1" stroke-opacity="0" class="path_vector_1" d="M340.156,170.078c0,93.926-76.146,170.074-170.077,170.074C76.146,340.152,0,264.004,0,170.078
    C0,76.146,76.147,0,170.079,0C264.011,0,340.156,76.146,340.156,170.078z">
          </path>
      </svg>
  </div>

jQuery

$('div').resizable();
like image 477
Patrik Avatar asked Jul 08 '15 13:07

Patrik


1 Answers

Add preserveAspectRatio="none" to the <svg> element E.g.

<svg style="width:100%; height:100%; " version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="340.156px" height="340.152px" viewBox="0 0 340.156 340.152" preserveAspectRatio="none" enable-background="new 0 0 340.156 340.152" xml:space="preserve">
like image 176
Robert Longson Avatar answered Oct 28 '22 02:10

Robert Longson