Изменить: не могу понять, как включить сюда jQuery, поэтому вот ручка:
https:/ /codepen.io/tactics/pen/xxNvYzV
Код: Выделить всё
$(document).ready(function() {
$("nav a").click(function() {
var $carousel = $('.carousel');
var scrollTo = $(this).attr('href');
// change its bg
.css('background', '#9f3')
// retrieve its position relative to its parent
.position().left;
console.log(scrollTo);
// simply update the scroll of the carousel
// $('.carousel').scrollLeft(scrollTo);
// use an animation to scroll to the destination
$carousel
.animate({
'scrollLeft': scrollTo
}, 500);
});
});
Код: Выделить всё
.carousel {
width: 300px;
height: 100px;
overflow-x: auto;
overflow-y: hidden;
}
.frame {
position: relative;
height: 100px;
width: 770px;
}
.frame div {
height: 90px;
width: 60px;
float: left;
margin: 5px;
background: #39f;
}
Код: Выделить всё
[url=#d1]1[/url]
[url=#d6]6[/url]
Подробнее здесь: https://stackoverflow.com/questions/786 ... ith-jquery