目前我正在一个网站上工作,我遇到了很多困难。基本上,我正在试图制作一个+形状的网站,该网站应该具有双向滚动系统。我努力使网站看起来是这样的:在+形网站上水平和垂直滚动
权证è
C C C
权证è
其中E是空的,不可见的空间。 C是一个实际的div,包含内容。所有内容div都将链接到彼此,因此用户可以访问该网站的其他部分。
因为我的jQuery和JavaScript不是最好的,我有很多麻烦让网站滚动链接单击操作。我终于设法让它与jQuery scrollTo库一起工作,但现在我有一个不同的问题。用户现在仍然可以滚动到网站的“空白”部分,这是一个很大的可用性问题。我试图通过使用overflow:hidden来关闭这个空的空间,但是这打破了整个滚动系统。同时,我还希望在进入网站时(box5),首先显示中间内容div。但是因为我的jQuery/Javascript技能目前非常糟糕,所以我很难让这个网站正常工作。
任何帮助,或向正确的方向轻推将不胜感激!
这是我目前的工作:
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<!--<link href="css/reset.css" rel="stylesheet" type="text/css" />-->
<link href="css/style.css" rel="stylesheet" type="text/css" />
<!-- Load jQuery (newer versions will not work) -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<!-- Load ScrollTo -->
<script src="http://flesler-plugins.googlecode.com/files/jquery.scrollTo-1.4.2-min.js"></script>
<!-- Load LocalScroll -->
<script src="http://flesler-plugins.googlecode.com/files/jquery.localscroll-1.2.7-min.js"></script>
<!-- Load Link Scrolling-->
<script src="js/init.js"></script>
</head>
<body>
<div id="box-links">
<!-- Temporary table as site reference -->
<table width="400" border="1" cellspacing="1" cellpadding="1">
<tr>
<td>(Empty)</a></td>
<td><a href="#box2" class="box2link">box2 (News)</a></td>
<td>(Empty)</a></td>
</tr>
<tr>
<td><a href="#box4" class="box4link">box4 (Day 1)</a></td>
<td><a href="#box5" class="box5link">box5 (Home/Index)</a></td>
<td><a href="#box6" class="box6link">box6 (Day 2)</a></td>
</tr>
<tr>
<td>(Empty)</td>
<td><a href="#box8" class="box8link">box8 (Unspecified)</a></td>
<td>(Empty)</td>
</tr>
</table>
</div><!-- end box-links-->
<div id="master_container">
<div id="box2" class="container">
</div>
<div id="box4" class="container">
</div>
<div id="box5" class="container">
</div>
<div id="box6" class="container">
</div>
<div id="box8" class="container">
</div>
</div> <!-- end master container-->
<footer>
</footer>
</body>
</html>
的style.css
@charset "utf-8";
/* Temporary placement of reset.css */
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
/*table, tr, th, td, tijdelijk uitgehaald */
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,
caption, tbody, tfoot, thead,
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;
}
/* HTML5 display-role reset for older browsers */
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;
}
/*====================================================================================*/
html, body {
width: 100%;
height: 100%;
}
#master_container{
width:300%;
height:300%;
min-width:3000px;
}
.container{
width: 33.2%;
height: 33.3%;
float: left;
background-color: #0CF;
border: 2px dashed #000;
}
#box2, #box8{
margin: 0 33.3% 0 33.3%;
}
footer{
position:fixed;
width:100%;
height:50px;
background-color:#F00;
bottom:0px;
}
init.js
jQuery(function($){
/**
* Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
* @see http://flesler.demos.com/jquery/scrollTo/
* You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
*/
// The default axis is 'y', but in this demo, I want to scroll both
// You can modify any default like this
$.localScroll.defaults.axis = 'xy';
// When the document is loaded...
$(document).ready(function()
{
// Scroll the whole document
$('#box-links').localScroll({
target:'body',
queue:true,
duration:1000,
hash:true,
onBefore:function(e, anchor, $target){
// The 'this' is the settings object, can be modified
},
onAfter:function(anchor, settings){
// The 'this' contains the scrolled element (#content)
}
});
});
});
请原谅我,如果我没到位代码在这里正确。
所以你基本上要一个单页网站 – 2013-07-16 18:31:46
搜索“单页网站”,您可能会发现您正在搜索的内容。 – putvande
我曾看过单页网站,这就是我对scrollTo Library的了解。尽管大多数单页网站不进行垂直和水平滚动。至少,我发现很难找到关于这方面的教程。 – user2588534