目前我正在一个网站上工作,我遇到了很多困难。基本上,我正在尝试制作一个 + 形状的网站,它应该具有双向滚动系统。我正在尝试使网站看起来像这样:
欧洲经委会
CCC
欧洲经委会
其中 E 是空的、不可见的空间。C 是一个实际的 div,里面有内容。所有内容 div 都会有相互链接,因此用户可以访问网站的其他部分。
因为我的 jQuery 和 JavaScript 不是最好的,所以我很难让网站在链接点击操作上滚动。我终于设法让它与 jQuery scrollTo 库一起工作,尽管现在我有一个不同的问题。用户现在仍然可以滚动到网站的“空白”部分,这是一个很大的可用性问题。我尝试使用溢出关闭这个空白空间:隐藏,但这会破坏整个滚动系统。同时,我还希望在进入站点(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>
样式.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;
}
初始化.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)
}
});
});
});
如果我没有在此处正确放置代码,请见谅。