Ad
JavaScript Slider Not Working As Expected
I am using Sly library for sliding a couple of divs. I am following their syntax:
<div id="wrapperSly">
<div class="frame" id="weatherSlider">
<div id="slidee">
{{#each forecast.data}}
<div id="0hrs">
<div id="0time">{{this.hour}}</div>
<div id="0currTemp">{{this.temp}}°</div>
</div>
{{/each}}
</div>
</div>
</div>
// js file:
let slyFrame = $('#weatherSlider');
let $slidee = $('#slidee');
let $wrap = slyFrame.parent();
// slyFrame.sly(false);
// Call Sly on frame
slyFrame.sly({
horizontal: 1,
itemNav: 'basic',
smart: 1,
activateOn: 'click',
mouseDragging: 1,
touchDragging: 1,
releaseSwing: 1,
startAt: 3,
scrollBy: 1,
activatePageOn: 'click',
speed: 300,
elasticBounds: 1,
easing: 'easeOutExpo',
dragHandle: 1,
dynamicHandle: 1,
clickBar: 1
}).init();
It almost works, the problem is that if I put 10 divs, for example, there are 9 divs next to each other ( working as expected ), but the last one is below the first. The same happens if I put 6 divs, for example. 5 are one next to each other and the last one is below.
Ad
Answer
This is probably a css issue - you need to set margins to 0 to make the items fit the container like this:
.frame { width: 100%; height: 160px; padding: 0; }
.frame .slidee { margin: 0; padding: 0; height: 100%; list-style: none; }
.frame .slidee li { float: left; margin: 0 5px 0 0; padding: 0; width: 120px; height: 100%; }
What’s your css look like?
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad