Log in

View Full Version : html5 mobile page sliding issues



mutago
11-13-2014, 08:40 PM
This code below works by sliding the content of DIV but what i want is
If user is on the firstpage and click on the links, it will slide him to secondpage in full and vice versa.
Any help will be appreciated.




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Page Slide</title>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script type="text/javascript">

$(function(){
var w = $(window).width();
var h = $(window).height();
var slides = $('.Slides > div');
$('.SlideContainer').css({ height: (h-60) + 'px' });
$('.Slides').css({ width: slides.length + '00%' });
slides.css({ width: w + 'px' });

var pos = 0;

$('.Left').click(function(){
pos--;
$('.Slides').animate({ left: (pos * w) + 'px' });
});
$('.Right').click(function(){
pos++;
$('.Slides').animate({ left: (pos * w) + 'px' });
});

});

</script>

<style type="text/css">

body { margin: 0; padding: 0; }

.Header { position: absolute; left: 0; top: 0; width: 100%; height: 30px; line-height: 30px; text-align: center; background: #000; color: #fff; }
.Footer { position: absolute; left: 0; bottom: 0; width: 100%; height: 30px; line-height: 30px; text-align: center; background: #000; color: #fff; }

.SlideContainer { position: absolute; left: 0; top: 30px; width: 100%; overflow: hidden; }
.Slides { position: absolute; left: 0; top: 0; height: 100%; }
.Slides > div { float: left; height: 100%; overflow: scroll; }

.Slides .Content { margin-top: 100px; text-align: center; }
.Slides .Content a { font-size: 30px; }

</style>

</head>
<body>


<div class="SlideContainer">
<div class="Slides">

<div class="Slide">
<div class="Content">
<h1>I am on the First Page</h1>
<a href="secondpage.html" class="Left">Slide Me to Secondpage</a>
</div>
</div>

<div class="Slide">
<div class="Content">
<h1>I am on the second page</h1>
<a href="firstpage.html" class="Left">Slide Me back to First Page</a>

</div>
</div>



</div>
</div>


</body>
</html>