.gallerycontainer{
position: relative;
height:500px;
/*Add a height attribute and set to largest image's height to prevent overlaying*/
}

.thumbnail img{
border: 1px solid white;
margin: 0 5px 5px 0;
}

.thumbnail:hover{
background-color: transparent;
}

.thumbnail:hover img{
border: 1px solid blue;
}

.thumbnail span{ /*CSS for enlarged image*/
position: absolute;
background-color: #FFFFC9;
padding: 10px;
visibility: hidden;
max-width: 80%;
color: black;
font-size: 1em;
text-decoration: none;
}

.thumbnail .imgquer img { /*CSS for enlarged image*/
border-width: 0;
padding: 0;
max-width: 630px;
width:100%;
height:auto;
}

.thumbnail .imghoch img { /*CSS for enlarged image*/
border-width: 0;
padding: 0;
max-height:500px;
width:auto;
height:100%;
}

.thumbnail:hover span { /*CSS for enlarged image*/
visibility: visible;
top: 25px;
left: 220px; /*position where enlarged image should offset horizontally */
z-index: 50;
}
@media only screen and (max-width:1100px) {
.thumbnail .imghoch img { max-height:450px; }
}
@media only screen and (max-width:830px) {
.thumbnail .imghoch img { max-height:450px; }
}
@media only screen and (max-width:670px) {
.thumbnail span{ max-width: 60%;}
.thumbnail .imghoch img { max-height:400px; }
}
@media only screen and (max-width:630px) {
.thumbnail > img        { display:none; }
.gallerycontainer      { height:100%;}
.thumbnail span       { position: static;visibility: visible;max-width: 90%;}
.thumbnail .imgquer img { visibility:visible; max-width:630px; width:100%;height:auto;}
.thumbnail .imghoch img { visibility:visible; max-width:630px; width:75%; height:auto;}
}