Crear Slideshow con jQuery

3 11

Anterior mente les había publicado el tema de Slider jQuery plugin , pero ahora les presento un código más desglosado y fácil de implementar.

Recuerden que para este ejemplo utilizamos JQuery

Codigo Html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<div id="button">
		 <a class="button1 active" rel="1" href="#"></a>
		 <a class="button2" rel="2" href="#"></a>
		 <a class="button3" rel="3" href="#"></a>
	</div> <!-- end of div button-->
 
	<div class="clear"></div>
 
	<div id="myslide">
		<div class="cover">
 
			<div class="mystuff">
				Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas pharetra, elit sed hendrerit condimentum, libero elit tincidunt mauris, id rutrum tellus leo at urna. Fusce dui mi, lacinia sit amet blandit vitae, interdum ut eros. Nulla egestas imperdiet rutrum. Praesent vel metus ligula. In ut leo enim, in interdum urna. In hac habitasse platea dictumst. Nullam euismod, eros et venenatis adipiscing, libero libero cursus magna, et semper tellus ipsum eget libero.
			</div>
			<div class="mystuff">
				Aenean scelerisque ipsum a nunc placerat sed blandit odio sollicitudin. Donec sed velit id ipsum lobortis tincidunt a sit amet leo. Praesent sit amet nisl a arcu lobortis egestas. Nunc at felis in erat condimentum ornare vel vel nisl. Phasellus ultrices nisi vel leo commodo et rhoncus ipsum porttitor. Fusce eu ligula sit amet sapien ullamcorper adipiscing. Suspendisse non ipsum elit. Nunc vehicula, felis non scelerisque aliquam, tellus leo consequat sem, ac suscipit nisi risus a justo. Quisque sollicitudin iaculis nisl at luctus. Curabitur porttitor lacus et dui blandit vulputate. In eu quam quam.
			</div>
			<div class="mystuff">
				Suspendisse iaculis sodales dui pretium faucibus. Praesent vitae ipsum justo, id tempor tellus. In nulla leo, dignissim quis luctus sed, commodo nec velit. Aliquam ac nisl quam, quis tincidunt magna. Aenean nec massa elit, non ornare neque. Vestibulum at ipsum sit amet augue euismod consequat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vivamus porttitor gravida massa at cursus. Sed ac viverra risus.
			</div>
 
		</div> <!-- end of div cover -->
	</div>  <!-- end of div myslide -->

Codigo Css

1
2
3
4
5
6
7
8
9
10
11
12
#myslide {width:160px;overflow:hidden;position: relative;height:170px;margin-bottom:20px}
 
	#myslide .cover{
		width:480px; /*------- class mystuff width * number of mystuff divs (160 * 3 = 480)---------- */
		position: absolute;
		height:160px;
	}
 
	#myslide .mystuff {width:160px;float:left;padding:20px 0;}
 
	.button1,.button2,.button3{background:#999;padding:6px;display:block;float:left;margin-right:5px;}
	.active{background:#111;padding:6px;display:block;float:left;outline:none;}

Codigo JavaScript

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/JavaScript">
$(document).ready(function (){
	$('#button a').click(function(){
		var integer = $(this).attr('rel');
		$('#myslide .cover').css({left:-160*(parseInt(integer)-1)}).hide().fadeIn(); /*----- Width of div mystuff (here 160) ------ */
		$('#button a').each(function(){
		$(this).removeClass('active');
			if($(this).hasClass('button'+integer)){
				$(this).addClass('active')}
		});
	});	
});
</script>

Ver Ejemplo

Espero sus comentarios

Processing your request, Please wait....

Similar articles

3 Comments

  1. muscle core x review 25 marzo 2013 at 1:49

    Hi, the whole thing is going well here and ofcourse every one is sharing facts,
    that’s genuinely fine, keep up writing.

  2. http://Www.Musclerevxtremereviews.org/ 14 marzo 2013 at 20:02

    Whats up very nice blog!! Guy .. Beautiful .. Superb .
    . I’ll bookmark your web site and take the feeds additionally? I’m satisfied
    to find numerous useful info right here within the submit, we want work out more techniques in this regard, thanks for sharing.

    . . . . .

  3. http://ghardknight71s.wordpress.com/ 5 febrero 2013 at 1:00

    Does your site have a contact page? I’m having problems locating it but, I’d like to send you an email.
    I’ve got some ideas for your blog you might be interested in hearing. Either way, great site and I look forward to seeing it improve over time.

Leave a reply

Your email address will not be published. Required fields are marked *