I'm using the Tiny scrol开发者_如何学运维lbar plugin with Jquery to view picture albums. It works fine except for one wrapping issue.
Example: http://67.23.251.125/~emelieze/test/index.php?t=collage&p=collage/Test&scroll=yes
As you probably can see the images (or rather the divs containing the images) is not arranged in a single row, they do so only as you scroll to the right. The overview-div has a fixed width and height, but it still wraps to the viewport-div (the black border makes it obvious.) The width of the overview-div is calculated with php so putting it in the stylesheet is not an option.
The scrollbar-div and it's content looks like this:
<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>
The 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;}
Inside head-tag:
$(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'});
});
How can I stop the overview-div from wrapping to the viewport-div?
You should set the overview to the same size as all the divs combined so 5 x 500 = 2500 pixels. The viewport should have a fixed size. it can be dynamic but then you will have to use the tinyscrollbar update method.
精彩评论