javascript - Resizing and centering an img in an "overflow: hidden" div -


I want to create a javascript / jquery function which will be used for any set dimension IMG (when the aspect ratio should be maintained) This will fill the size of any set dimension, without any interval, the parent div (which is overflow: hidden set)

How far was it far:

This image should change the size of the parent, in whatever dimension (width or height) the biggest difference between the self and the parent And is, P>

  $. Create a memory copy of the image in the image ($ (".img_for_video_thumbnail"), function (index, value) {$ ("& lt; img / & gt;") // to avoid CSS issues .attr ("src" , $ (This) .attr ("src")) .load (function () {var pic_real_width, pic_real_height, width_difference, height_difference; var pic_real_width = this.width; // note: $ (this) .width () var pic_real_height = This.height; // will not work in memory images var parent_width = this.parent (). Width; var parent_height = this.parent (). Height; var width_difference = pic_real_width - parent_width; var height_difference = pic_real_height - parent_height; If (width_difference & gt; = height_difference) {// do something ... but what?}}}}});   

I'm using Django with Google App Engine.

Done! < / P>

(Edit I have made a mistake and correct it)

Just click the button to see the function Child button.

Good luck coding

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -