javascript - jQuery/CSS: Changing the height and width attributes of an image when clicked -


i'm working on simple gallery built html, css, , jquery. when user clicks on image, larger version of image should pop in frame overlay behind it. have no problems horizontally-oriented images, vertically-oriented images, larger image comes out distorted.

you can view working sample on codepen: http://codepen.io/anfperez/pen/axzgrv

i try change the attributes of image saving height of image in variable , changing attribute using jquery, doesn't seem working.

how can access height , width of larger image url , put frame? trying following code, did not work.

var height_large = $(this).attr('height')  var width_large = $(this).attr('width')  $('#frame img').attr('height', height_large) $('#frame img').attr('width', width_large) 

for reference, here actual url of photo i'm trying pull down: https://farm8.staticflickr.com/7072/7274940170_c166072ddf_c.jpg

changing height auto #frame img worked me. displays larger image fixed width , accomodates height accordingly. renders proportionally correct. you'll want make sure images @ least wide fixed width start avoid upscaling.

#frame img {   display: none;    position: fixed;   background-color: white;   width: 700px;   height: auto;   margin-left: -350px;   left: 50%; } 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -