Riccardo New R Bernucci Riccardo New R Bernucci - 12 days ago 7
CSS Question

Slider Transform button into arrow

Could I transform the button of this slider into two arrows "Next - Previous" ?!
In this case I have a button for each slide, I had to use only two button, but how can I transform input in next and previous?! with a simple js or I could fix problem with css?!

<div id="slider-wrapper">
<input type="radio" id="button-1" name="buttons" checked="checked"/>
<label for="button-1"></label>
<input type="radio" id="button-2" name="buttons"/>
<label for="button-2"></label>
<input type="radio" id="button-3" name="buttons"/>
<label for="button-3"></label>
<input type="radio" id="button-4" name="buttons"/>
<label for="button-4"></label>
<input type="radio" id="button-5" name="buttons"/>
<label for="button-5"></label>

<div id="slider">
<ul>
<li id="slide1">

<img src="images/img1.jpg" width="400" height="400" alt=""/> </li>
<li id="slide2">
<p>Slider Page Two<br>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.</p>
</li>
<li id="slide3">
<p>Slider Page Three<br>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.</p>
</li>
<li id="slide4">
<p>Slider Page Four<br>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.</p>
</li>
<li id="slide5">
<p>Slider Page Five<br>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.</p>
</li>
</ul>
</div>
</div>


Fiddle

http://jsfiddle.net/tMxp5/274/

Thank You .

Zak Zak
Answer

Using a bit of jQuery, I've come up with this, obviously it would need a bit more work for instance to stop when it gets past the last slider page. You should probably also use transform: translate3d() instead of left as the transition will be smoother, particularly on smartphones.

http://jsfiddle.net/tMxp5/275/

var left = 0;

$('#button-1').click(function() {
    left = left + 100;
    $('#slider ul').css({left: left + '%'});
});

$('#button-2').click(function() {
    left = left - 100;
    $('#slider ul').css({left: left + '%'});
});