Last active
December 14, 2015 14:48
-
-
Save marcosanchez/5102973 to your computer and use it in GitHub Desktop.
Este slider incorpora un par de códigos que andan por Internet. Uno para hacer sliders estilo acordeón y otro para moverse al inicio del slider. Ejemplo: http://www.edutec2013.ac.cr/presentacionpone.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* En los estilos es conveniente lo siguiente: */ | |
#slider div div { | |
display: none; /* esto oculta los sliders en posición de descanso inicial */ | |
} | |
#slider div a { | |
cursor:pointer; /* esto cambia el cursos a mano para hacer ver que es un vínculo */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<script> window.jQuery || document.write('<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">\x3C/script>') </script> | |
<script type="text/javascript" ></script> | |
$(document).ready(function() { | |
$('#slider > div > a').click(function(){ | |
if ($(this).attr('class') != 'active'){ | |
$('#slider div a').removeClass('active'); | |
$(this).addClass('active'); | |
$('#slider div div').slideUp(); | |
$(this).next().slideToggle(); | |
$('html, body').animate({scrollTop: $("#slider").offset().top}, 400); | |
} else { | |
$(this).removeClass('active'); | |
$('#slider div div').slideUp(); | |
$('html, body').animate({scrollTop: $("#slider").offset().top}, 400); | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="slider"> | |
<div> | |
<p>Cualquier contenido</p> | |
<a>Vínculo que desplegará el slider 1</a> | |
<div> | |
<p>Contenido del slider 1</p> | |
</div> | |
</div> | |
<div> | |
<p>Cualquier contenido</p> | |
<a>Vínculo que desplegará el slider n</a> | |
<div> | |
<p>Contenido del slider n</p> | |
</div> | |
</div> | |
<!-- se repite el código de los sliders para incluir cuantos sean necesarios --> | |
</div> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment