$(function() {
// count your slide elements
var elementCount = $('.some').length;
// width of the first element
var width = $('.some').first().width();
// full width of all elements
var fullWidth = elementCount*width;
// scroll left value
var scrollLeft = width;
// update values after resizing
$(window).on('resize', function() {
width = $('.some').first().width();
scrollLeft = width;
fullWidth = elementCount*width;
$("#feedTxt").scrollLeft(0);
});
$("#SLIDE").click(function() {
// if full width smaller or equal to your scroll left, than scroll to the beginning
if((fullWidth) <= scrollLeft) {
scrollLeft = 0;
}
// animate scroll left
$("#feedTxt").animate({scrollLeft: scrollLeft}, 800);
// if the full width not equal to scroll left, add width to scrollLeft
if((fullWidth) !== scrollLeft) {
scrollLeft += width;
}
}); \t
});
#feedTxt {
display: flex;
overflow-x: scroll;
height:450px;
width:100%;
}
.some {
flex: 0 0 100%;
height: 450px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div align="center" id="feedTxt">
<div class="some">
<h1>title 1</h1>
<br>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </p>
</div>
<div class="some">
<h1>title 2</h1>
<br>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </p>
</div>
<div class="some">
<h1>title 3</h1>
<br>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </p>
</div>
<div class="some">
<h1>title 4</h1>
<br>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </p>
</div>
</div>
<button id="SLIDE">Press to slide</button>
この "' $」 1次回() .animate(してみてください(" 一部。){ "のmargin-left":-widths}、 "" 遅い) .nextを( '.some') .animate({ "マージン左":-widths}、 "遅い") .END(); \t}); ' – kukkuz