title: How to zoom image from center without using exact position
body: <p>I have a picture in html code.</p>
  
  <p>I use jquery to zoom it when mouse on image - but the image zooms from left and top and I want it to zoom from center.</p>
  
  <p>I searched in stackOverFlow and every one use position attr but I don't use it.</p>
  
  <p>This is my sample code:</p>
  
  <pre><code>&lt;div class="flex-col
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let image = $('#navigation_bar img');
  
  $('#menu-item-948').hover(function() {
  
    //   alert("top :"+position.top +" left : "+ position.left +" right: "+ position.right +" bottom: "+ position.bottom);
    $(image)
      .attr("src", "https://matiloos.dts.company/wp-content/uploads/2018/11/Asset-6.png")
      .animate({
          width: "5rem",
          height: "5rem",
          top: "0.5f",
          left: "0.5f"
        },
        50);
    $('#menu-item-948').append('&lt;p id="text" &gt;text&lt;/p&gt;');
    $('#text').css('color', '#55EA00');
  
  }, function() {
    $(image)
      .attr("src", "https://matiloos.dts.company/wp-content/uploads/2018/11/Asset-5.png")
      .animate({
        width: "2.5rem",
        height: "2.5rem"
      }, 300);
    $('#text').remove();
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="flex-col hide-for-medium flex-center" style="margin-left: 50%; margin-top: 10%"&gt;
    &lt;ul id="navigation_bar" class="nav header-nav header-bottom-nav nav-center  nav-divided nav-uppercase text-center "&gt;
      &lt;li id="menu-item-948" class="menu-item menu-item-type-post_type menu-item-object-page  menu-item-948"&gt;
        &lt;a href="https://matiloos.dts.company/demos/shop-demos/big-sale/" class="nav-top-link"&gt;&lt;img id="pic1" src="https://matiloos.dts.company/wp-content/uploads/2018/11/Asset-5.png" style="position:relative;width: 2.5rem; height: 2.5rem"&gt;&lt;/a&gt;
      &lt;/li&gt;
    &lt;/ul&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have many of this picture in navigation bar.</p>