Looking for assistance with a JavaScript issue that I'm currently facing.
Q1: Javascript Function to Return Image Height and Margin
My website layout consists of a horizontal scroll of smaller images arranged in a grid, each with different height percentages and margins for positioning. When an image is clicked, it expands to height:100% and margin:0, clearing all previous styles to create a simple large image layout.
My query is, how can I implement a function that returns the height and margins to their original CSS settings when clicking on .image-container?
JS Fiddle Demo (click any center image)
// GALLERY 100% height
$('.image-container').click(function(){
$('.image-container img').animate({'height': '100%'},900)
.animate({'margin': '0'},900);
});
// ? REMOVE HEIGHT ?
$('.image-container').click(function(){
$('.image-container img').animate({'height': '?'},900)
.animate({'margin': '?'},900);
});
EDIT UPDATED QUESTION: Q2 HOW TO MAKE PAGE SIZE GROW WITH LARGER IMAGES
Currently, my .image-container is set to a large width. However, with responsive images, it's challenging to determine the correct width. Is there a way to dynamically adjust the width to accommodate larger images when clicked (as shown above)?
.image-container {
display:block;
width:3600px;
height: 75%;
float:left;
position:absolute;
top: 13%;
left: 120px;
z-index: -1;
Thank you for any assistance!