Одна страница на jQuery
Достаточно простой пример того, как создать одно страничный сайт с навигацией, в данном примере (3х3)
1 2 3
4 5 6
7 8 9
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Одна страница</title>
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<style>
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
::-moz-selection { background: #fe57a1; color: #fff; text-shadow: none; }
::selection { background: #fe57a1; color: #fff; text-shadow: none; }
a:hover, a:active { outline: 0; }
body {
font-family: arial;
font-size: 15px;
overflow: hidden;
}
h2 {
color: #ffffff;
text-align: center;
font-family: Verdana;
font-size: 54px;
margin-top: 50px;
}
h3 {
color: #ffffff;
text-align: center;
font-family: Verdana;
font-size: 16px;
margin-top: 20px;
}
p {
color: #ffffff;
text-align: center;
font-family: arial;
font-size: 16px;
line-height: 24px;
margin-top: 20px;
}
.contentul {
text-align: center;
font-size: 16px;
line-height: 24px;
color: #ffffff;
}
nav {
height: 50px;
width: 100%;
}
nav ul li {
height: 50px;
width: 11.1%;
text-align: center;
float: left;
}
nav ul li a {
text-decoration: none;
color: #ffffff;
line-height: 50px;
display: block;
}
#link1 {background: #fe4632;}
#link2 {background: #005fe5;}
#link3 {background: #ffb40a;}
#link4 {background: #80bf34;}
#link5 {background: #26bfa3;}
#link6 {background: #2d93cf;}
#link7 {background: #ab250f;}
#link8 {background: #e99702;}
#link9 {background: #9adf56;}
.box {float: left;}
#box1 {background: #fe4632;}
#box2 {background: #005fe5;}
#box3 {background: #ffb40a;}
#box4 {background: #80bf34;}
#box5 {background: #26bfa3;}
#box6 {background: #2d93cf;}
#box7 {background: #ab250f;}
#box8 {background: #e99702;}
#box9 {background: #9adf56;}
</style>
<script>
$(document).ready(function(){
function resizeBoxes() {
var browserWidth = $(window).width();
var browserHeight = $(window).height();
$('#main').css({
width: browserWidth*3,
});
$('.box').css({
width: browserWidth,
height: browserHeight,
});
}
resizeBoxes();
$(window).resize(function() {
resizeBoxes();
});
$('nav ul li a').click(function(){
return false;
});
function goTo(horizontal,vertical) {
var browserWidth = $(window).width();
var browserHeight = $(window).height();
$('#main').animate({
marginLeft: '-'+browserWidth*horizontal,
marginTop: '-'+browserHeight*vertical,
}, 1000);
}
$('#link1 a').click(function(){
goTo(0,0);
});
$('#link2 a').click(function(){
goTo(1,0);
});
$('#link3 a').click(function(){
goTo(2,0);
});
$('#link4 a').click(function(){
goTo(0,1);
});
$('#link5 a').click(function(){
goTo(1,1);
});
$('#link6 a').click(function(){
goTo(2,1);
});
$('#link7 a').click(function(){
goTo(0,2);
});
$('#link8 a').click(function(){
goTo(1,2);
});
$('#link9 a').click(function(){
goTo(2,2);
});
});
</script>
</head>
<body>
<div id="main">
<section id="box1" class="box">
<nav>
<ul>
<li id="link1"><a href="#">1</a></li>
<li id="link2"><a href="#">2</a></li>
<li id="link3"><a href="#">3</a></li>
<li id="link4"><a href="#">4</a></li>
<li id="link5"><a href="#">5</a></li>
<li id="link6"><a href="#">6</a></li>
<li id="link7"><a href="#">7</a></li>
<li id="link8"><a href="#">8</a></li>
<li id="link9"><a href="#">9</a></li>
</ul>
</nav>
<h2>1</h2>
</section>
<section id="box2" class="box">
<nav>
<ul>
<li id="link1"><a href="#">1</a></li>
<li id="link2"><a href="#">2</a></li>
<li id="link3"><a href="#">3</a></li>
<li id="link4"><a href="#">4</a></li>
<li id="link5"><a href="#">5</a></li>
<li id="link6"><a href="#">6</a></li>
<li id="link7"><a href="#">7</a></li>
<li id="link8"><a href="#">8</a></li>
<li id="link9"><a href="#">9</a></li>
</ul>
</nav>
<h2>2</h3>
</section>
<section id="box3" class="box">
<nav>
<ul>
<li id="link1"><a href="#">1</a></li>
<li id="link2"><a href="#">2</a></li>
<li id="link3"><a href="#">3</a></li>
<li id="link4"><a href="#">4</a></li>
<li id="link5"><a href="#">5</a></li>
<li id="link6"><a href="#">6</a></li>
<li id="link7"><a href="#">7</a></li>
<li id="link8"><a href="#">8</a></li>
<li id="link9"><a href="#">9</a></li>
</ul>
</nav>
<h2>3</h2>
</section>
<section id="box4" class="box">
<nav>
<ul>
<li id="link1"><a href="#">1</a></li>
<li id="link2"><a href="#">2</a></li>
<li id="link3"><a href="#">3</a></li>
<li id="link4"><a href="#">4</a></li>
<li id="link5"><a href="#">5</a></li>
<li id="link6"><a href="#">6</a></li>
<li id="link7"><a href="#">7</a></li>
<li id="link8"><a href="#">8</a></li>
<li id="link9"><a href="#">9</a></li>
</ul>
</nav>
<h2>4</h2>
</section>
<section id="box5" class="box">
<nav>
<ul>
<li id="link1"><a href="#">1</a></li>
<li id="link2"><a href="#">2</a></li>
<li id="link3"><a href="#">3</a></li>
<li id="link4"><a href="#">4</a></li>
<li id="link5"><a href="#">5</a></li>
<li id="link6"><a href="#">6</a></li>
<li id="link7"><a href="#">7</a></li>
<li id="link8"><a href="#">8</a></li>
<li id="link9"><a href="#">9</a></li>
</ul>
</nav>
<h2>5</h2>
</section>
<section id="box6" class="box">
<nav>
<ul>
<li id="link1"><a href="#">1</a></li>
<li id="link2"><a href="#">2</a></li>
<li id="link3"><a href="#">3</a></li>
<li id="link4"><a href="#">4</a></li>
<li id="link5"><a href="#">5</a></li>
<li id="link6"><a href="#">6</a></li>
<li id="link7"><a href="#">7</a></li>
<li id="link8"><a href="#">8</a></li>
<li id="link9"><a href="#">9</a></li>
</ul>
</nav>
<h2>6</h2>
</section>
<section id="box7" class="box">
<nav>
<ul>
<li id="link1"><a href="#">1</a></li>
<li id="link2"><a href="#">2</a></li>
<li id="link3"><a href="#">3</a></li>
<li id="link4"><a href="#">4</a></li>
<li id="link5"><a href="#">5</a></li>
<li id="link6"><a href="#">6</a></li>
<li id="link7"><a href="#">7</a></li>
<li id="link8"><a href="#">8</a></li>
<li id="link9"><a href="#">9</a></li>
</ul>
</nav>
<h2>7</h2>
</section>
<section id="box8" class="box">
<nav>
<ul>
<li id="link1"><a href="#">1</a></li>
<li id="link2"><a href="#">2</a></li>
<li id="link3"><a href="#">3</a></li>
<li id="link4"><a href="#">4</a></li>
<li id="link5"><a href="#">5</a></li>
<li id="link6"><a href="#">6</a></li>
<li id="link7"><a href="#">7</a></li>
<li id="link8"><a href="#">8</a></li>
<li id="link9"><a href="#">9</a></li>
</ul>
</nav>
<h2>8</h2>
</section>
<section id="box9" class="box">
<nav>
<ul>
<li id="link1"><a href="#">1</a></li>
<li id="link2"><a href="#">2</a></li>
<li id="link3"><a href="#">3</a></li>
<li id="link4"><a href="#">4</a></li>
<li id="link5"><a href="#">5</a></li>
<li id="link6"><a href="#">6</a></li>
<li id="link7"><a href="#">7</a></li>
<li id="link8"><a href="#">8</a></li>
<li id="link9"><a href="#">9</a></li>
</ul>
</nav>
<h2>9</h2>
</section>
</div>
</body></html>
На правах рекламы: Strombafort стромбафорт купить. . Modern expo group стеллажи.