Simple Javascript solution of on click get bigger picture effect

Hi from freezing and dark York UK,

On this page http://www.davidclick.com/clickimage.html there is a grid of thumbnail pics. I would like a cross browser solution to making bigger images appear when thumbnails are clicked on a bit like what is shown here:
http://demo.dougv.com/js_larger_image/index.html?_ga=1.260770633.518104102.1459365477

I’m looking for a simple as possible solution as my CSS brain / Javascript is embryonic :smile:

If anyone has an idea what could easily be added to the code without a major overhaul i would be eternally grateful but it has to be cross browser compatible ::smile:
Thanks in advance,
David

Ok found this:
http://www.kevinandamanda.com/whatsnew/javascript-tutorial-mouseover-an-image-thumbnail-to-get-a-pop-up-preview

Would this do the job, seams straight forward but are there any snags a rookie might not see if i went with this?

Some kind of light box script, like this

or this
http://www.jacklmoore.com/colorbox/
I’ve used the first one, you don’t need to know javascript to get it going.

1 Like

I think it was @coothead wrote a nice solution without JS recently.

1 Like

Stone me mate, you have an absolutely amazing memory. :sunglasses:

I had to search through my old posts and eventually found
the post to which you referred - 15th October, 2015.

Even then I had to run the code before I had a certain amount
of memory recall. :mask:

This is that code…

[code]

untitled document #holder { position:relative; width:15%; padding-bottom:10%; box-sizing:border-box; margin:0 auto; } #holder input{ display:none; } #holder label { position:absolute; width:100%; padding:2px; border:1px solid #999; box-sizing:border-box; background-color:#fff; box-shadow:0 0 0 #999; cursor:pointer; transition:all 2s ease-in-out; } #holder label::after { content:'description'; display:block; padding:0; font-size:0; color:#fff; text-align:center; background-color:#fff; transition:all 2s ease-in-out; } #holder label img { display:block; width:100%; border:1px solid #000; box-sizing:border-box; } #cb:checked~label { width:450%; /************************************************* The margin-left value is the final label width minus the intial label width divided by two. In this case (450-100)/2 = 175 **************************************************/ margin-left:-175%; padding:6px; border:3px solid #999; box-shadow:6px 6px 6px #999; } #cb:checked~label::after { padding:5px 0; font-size:100%; background-color:#333; }

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sit amet sem sed libero bibendum tempus faucibus quis mi. Nulla rhoncus vel ipsum in volutpat. Nam tortor nibh, posuere ac lorem ut, suscipit tincidunt leo. Duis interdum justo ac justo vehicula consequat. Curabitur et volutpat nibh. Phasellus rutrum lacus at dolor placerat feugiat. Morbi porta, sapien nec molestie molestie, odio magna vestibulum lorem, vitae feugiat est leo sit amet nunc. Curabitur ornare tempor turpis. In nibh sem, porta ac magna sed, pretium commodo odio. Sed porttitor augue velit, quis placerat diam sodales ac. Curabitur vitae porta ex. Praesent rutrum ex fringilla tellus tincidunt interdum. Proin molestie lectus consectetur purus aliquam porttitor. Fusce ac nisi ac magna scelerisque finibus a vitae sem.

[/code]

coothead

4 Likes

Well, I’ll be jiggered - it was that long ago! :smile:

1 Like

Well, as Virgil observantly wrote some little while ago…

“Tempus fugit”

coothead

1 Like

Thanks @SamA74, me thinks your solution is better for my skill level, I’ll give this a go and update progress here :slight_smile:

@SamA74 That worked thank you!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.