Skip to content

Instantly share code, notes, and snippets.

@jackabox
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save jackabox/f30ffb7b90ac9ea69226 to your computer and use it in GitHub Desktop.

Select an option

Save jackabox/f30ffb7b90ac9ea69226 to your computer and use it in GitHub Desktop.
Overflowing horizontally div, which scrolls on hot spot hover.
$(".hot-spot.left").hover(function() {
$('.study-gallery').animate({scrollLeft: 0}, 7000);
}, function() {
$('.study-gallery').stop();
});
$(".hot-spot.right").hover(function() {
$('.study-gallery').animate({scrollLeft: $('.gallery-container').width()}, 7000);
}, function() {
$('.study-gallery').stop();
});
<div class="study-gallery-wrap">
<div class="study-gallery">
<div class="gallery-container">
<img src="img/samples/photo08.jpg" alt="">
<img src="img/samples/photo09.jpg" alt="">
<img src="img/samples/photo10.jpg" alt="">
<img src="img/samples/photo11.jpg" alt="">
<img src="img/samples/photo12.jpg" alt="">
<img src="img/samples/photo13.jpg" alt="">
<img src="img/samples/photo14.jpg" alt="">
</div>
</div>
<div class="hot-spot left"></div>
<div class="hot-spot right"></div>
</div>
.study-gallery-wrap {
position: relative;
.hot-spot {
position: absolute;
z-index: 50;
top: 0;
bottom: 0;
display: block;
width: 150px;
height: 600px;
content: '';
background-repeat: repeat-x;
&.left {
left: 0;
}
&.right {
right: 0;
}
&:hover {
cursor: pointer;
}
}
}
.study-gallery {
position: relative;
overflow-x: scroll;
overflow-y: hidden;
height: 600px;
margin-bottom: 20px;
.gallery-container {
display: inline-block;
display: table;
overflow-y: hidden;
height: 600px;
white-space: nowrap;
}
img {
display: inline-block;
width: auto;
height: 100%;
}
}
@aranwilcox

Copy link
Copy Markdown

Great gallery Jake! :)

@jackabox

Copy link
Copy Markdown
Author

Cheers Aran!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment