我正在使用带有Jquery的Tiny滚动条插件来查看图片专辑。除了一个包装问题,它工作正常。
示例:http://67.23.251.125/~emelieze/test/index.php?t=collage&p=collage/Test&scroll=yes
正如您可能看到的那样,图像(或者更确切地说是包含图像的div)并未排列在一行中,只有当您向右滚动时才会这样。 overview-div有一个固定的宽度和高度,但它仍然包装到viewport-div(黑色边框使它显而易见。)overview-div的宽度是用php计算的,所以把它放在样式表中不是一个选项
scrollbar-div及其内容如下所示:
<div id='scrollbar2' >
<div class='viewport' style='height: 330px; '>
<div class='overview' style='width: 2560px; height: 330px; '>
<div class='scrollimage' style='width: 500px;'>
<img src='cms/album/collage/Test/blue.png'>
<br>
example 3</div>
<div class='scrollimage' style='width: 500px;'>
<img src='cms/album/collage/Test/green.png'>
<br>
example 5</div>
<div class='scrollimage' style='width: 500px;'>
<img src='cms/album/collage/Test/orange.png'>
<br>
example 1</div>
<div class='scrollimage' style='width: 500px;'>
<img src='cms/album/collage/Test/red.png'>
<br>
example 4</div>
<div class='scrollimage' style='width: 500px;'>
<img src='cms/album/collage/Test/yellow.png'>
<br>
example 2</div>
</div>
</div>
<div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div></div></div></div></div></div></div>
CSS:
#scrollbar2 { margin: 0px auto 40px auto; clear: both;}
#scrollbar2 .viewport { overflow: hidden; position: relative; }
#scrollbar2 .overview { list-style: none; padding: 0; margin: 0; position: absolute; border: 1px solid black; overflow: hidden;}
#scrollbar2 .scrollbar { position: relative; overflow: hidden; margin: 0px; clear: both; height: 15px; }
#scrollbar2 .track { background-color: #EEE; height:4px; position: relative; padding: 0px; }
#scrollbar2 .thumb { background-color: #CCC; background-position: 100% -15px; height: 4px; cursor: pointer; overflow: hidden; position: absolute; left: 0; top: 0px; }
#scrollbar2 .thumb .end{ overflow: hidden; background-position: 0 -15px; height: 13px; width: 5px;}
#scrollbar2 .disable { display: none; }
.scrollimage {float: left; border: 0px solid #000; position:relative; margin:0px 10px 0px 0px;}
内部标签:
$(document).ready(function(){var scroll = $('#scrollbar2,.scrollbar,.small_menu,.track,.viewport');
scroll.css('width', (screen.width)/1.5 + 'px')});
$(window).bind('load',function(){
$('#scrollbar2').tinyscrollbar({ axis: 'x'});
});
如何阻止overview-div包装到viewport-div?
答案 0 :(得分:1)
您应该将概览设置为与所有div组合相同的大小,以便5 x 500 = 2500像素。视口应具有固定大小。它可以是动态的,但是你必须使用tinyscrollbar更新方法。