Nová ukázka
Reset
Načíst z URL
Uložit a získat odkaz
Vztahuje se k…
Nevyplňujte
Napiště „nejsem robot“
▶
Přepnout zobrazení
Výsledek
<!doctype html> <html> <head> <script src="http://code.jquery.com/jquery-1.11.1.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script> <script> $(function() { function flip(element, speed, over) { var $front = $('.front', element); var $back = $('.back', element); if (!$(':animated', element).length && $back.is('.last') && !over) return; $front.switchClass('front', 'back', speed, function() { $back.switchClass('back', 'front', speed, function() { if ($back.is('.last') && !over) flip(element, speed, false); }); }); } $('.flip').each(function() { $(':first-child', this) .addClass('front') .next() .addClass('back last') .nextAll() .hide(); }); $(document).on({ mouseenter: function() { flip(this, 250, true); }, mouseleave: function() { flip(this, 250, false); } }, '.flip'); }); </script> <link href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/smoothness/jquery-ui.css" rel="stylesheet" /> <style> .flip { position: relative; overflow: hidden; width: 200px; height: 200px; } .flip img { position: absolute; top: 0; left: 0; margin-left: 0; height: 100%; opacity: 0; } .flip .front { width: 100%; opacity: 1; } .flip .back { margin-left: 50%; width: 0; } </style> </head> <body> <div class="flip"> <img src="http://malsup.github.com/images/beach2.jpg" /> <img src="http://malsup.github.com/images/beach3.jpg" /> </div> </body> </html>
HTML
Autoformát
Standardní režim
Mobilní zobrazení
CSS
Autoformát
CSS reset
Až na konci
J
ava
S
cript
Autoformát
jQuery
Umístění JS
window.onload
</head>
</body>