image - A javascript that sets a height/margin if img is a certain height -
basically want do, set img height 100% if shorter 160px/10em on screen. have no experience javascript though. after few googles came up.
if ($('#photo_crop img').height() < 160) { ('#photo_crop img').style.height = "100%";} however surprising not work. here html use.
<div id="photo_crop"><img src="{photourl-highres}" alt="{photoalt}" /></div> and css.
#photo_crop { height:64%; overflow:hidden; } #photo_crop img { transition:margin-bottom 0.333s, margin-top 0.333s; margin-bottom:-16%; margin-top:-16%; z-index:-1; } #photo_crop:hover { height:100%; } #photo_crop img:hover { margin-bottom:0; margin-top:0; } as can see code crops picture until hover on shows entire picture.this save space on tumblr blog. works great unless wide picture, example panorama because panorama cropped , way small. solving appreciated.
there no "then" in javascript. forgot second $-sign in front of second brackets , guess can not use "100%" check height.
Comments
Post a Comment