html - Scale image from the middle using jQuery -
is possible make image scale middle jquery? right it's going top left.
$( document ).ready(function() { $("#logo").animate({ height: '+=100%', width: '+=100%' }); });
#logoblock { position: relative; width: 700px; height: 700px; margin: auto; } #logo { position: absolute; width: 0%; height: 0%; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <div id="logoblock"> <div id="logo"> <img src="http://placehold.it/700x700"> </div> </div>
is possible?
may b not want
$( document ).ready(function() { $("#logo").animate({ height: '+=100%', width: '+=100%', top: 0, left:0 }); });
css
#logoblock { position: relative; width: 700px; height: 700px; margin: auto; } #logo { position: absolute; top:50%; left:50%; width: 0%; height: 0%; }
fiddle http://jsfiddle.net/73h17m1t/
click run
button after fiddle loaded , resize result frame full size best view.
Comments
Post a Comment