我知道这与书中的每个可用性规则都相悖,但是否有任何想法可以强制垂直滚动条水平滚动?
所以,如果:
用户查看页面并向下滚动,则页面将水平滚动?
谢谢!
非常尊重地说,这听起来是一件非常奇怪的事情,我的初步测试显示它是可行的,但结果实际上毫无用处。试试这个:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Scrolling test</title>
<!-- jQuery library - I get it from Google API's -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$(window).scroll(function(event){
var topScroll = $(window).scrollTop();
var leftScroll = $(window).scrollLeft();
$(window).scrollLeft(topScroll);
$("body").css("padding-top", leftScroll);
});
});
</script>
<style type="text/css">
h1 {
font-family: Verdana, Arial, sans-Serif;
font-size: 46px;
display: block;
white-space:nowrap;
}
body {
height: 1000px;
}
</style>
</head>
<body>
<div id="content"><h1>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur tincidunt dictum rhoncus. Phasellus nulla nulla, facilisis eu aliquam aliquet, mattis pulvinar purus. </h1></div>
</body>
</html>
由于滚动是在实际的浏览器窗口本身上进行的,因此似乎不可能捕获滚动事件并阻止其传播。我尝试使用jQuery(event.stopPropagation),但没有成功。所以我转而向body添加顶部填充,以营造没有发生垂直滚动的假象。但我认为这种方法不适合在实际环境中使用,因为结果很糟糕。 :-)
尽管如此,探索这个问题还是很有趣的!
祝好, Thomas Kahn
<div id='first'>
<div id='second'>
<!-- content -->
</div>
</div>
CSS:
#first {
overflow:hidden;
height:9000px;
}
#second {
width:9000px;
position:fixed;
}
JS:
window.onscroll=function() {
var scroll = window.scrollY;
$('#second').css('left', '-' + scroll + 'px');
}
创建了一个小型的示例: