我有点在整个互联网上搜索这个,希望你们能帮助我。
我有一个并排的 div 容器(图像)“条纹”,整体比视口宽,因此它们强制水平滚动。在一定数量的容器之后应该有“特殊容器”——当它们到达视口的左边界时——粘在左边(所以它们基本上是固定的)。随着滚动的继续,下一个“特殊容器”接近,它将第一个推到视线之外并取而代之,所以它也粘在左边,依此类推。
基本上我想实现这样的东西,但水平:http: //jsfiddle.net/f3y9s/1/
我的 HTML:
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>-</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/projekt.css" title="nofilter">
<script src="js/jquery-1.2.6.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.serialScroll-1.2.2-min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/waypoints.js"></script>
<script src="js/waypoints-sticky.js"></script>
<script type="text/javascript" charset="utf-8">
$(function(){
$(".post").wrapInner("<table><tr>");
$("img").wrap("<td>");
});
$(function(){
$("#projektimg").wrapInner("<table><tr>");
$(".post").wrap("<td>");
});
</script>
<!--<script type="text/javascript" charset="utf-8">
$('.my-sticky-element').waypoint(function(direction) {
$body.toggleClass(this.id + '-visible', direction === 'right');
}, {
horizontal: true
});</script>-->
<script>$(document).ready(function () {
$('.my-sticky-element').waypoint(function (direction) {
if (direction=='right')
$('.my-sticky-element').addClass('fixed');
else {
$('.my-sticky-element').removeClass('fixed');
}
}, {
horizontal: true
});
});</script>
</head>
<body>
<div class="my-sticky-element">
project description goes here
</div>
<div id="projektimg">
<div class="post">
<img src="img/1.jpg"/>
<img src="img/2.jpg"/>
<img src="img/3.jpg"/>
<img src="img/4.jpg"/>
<img src="img/5.jpg"/>
</div>
</div>
</body>
</html>
我的 CSS:
/* Global */
/* Reset */
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, font, 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,table, caption, tbody, tfoot, thead, tr, th, td {margin: 0;padding: 0;border: 0;outline: 0;font-size: 100%;vertical-align: baseline;background: transparent;}body {line-height: 1;}ol, ul {list-style: none;}blockquote, q {quotes: none;}/* remember to define focus styles! */:focus {outline: 0;}/* remember to highlight inserts somehow! */ins {text-decoration: none;}del {text-decoration: line-through;}/* tables still need 'cellspacing="0"' in the markup */table {border-collapse: collapse;border-spacing: 0;}
* {
padding:0;
margin:0;
border: none;
}
body {
background-color: #ffffff;
font-family: Helvetica, sans-serif;
font-size: 11px;
color: #000;
}
a {
text-decoration: none;
color: #282828;
-webkit-transition: color .2s;
-moz-transition: color .2s;
-o-transition: color .2s;
-ms-transition: color 0,2s;
transition: color .2s;
}
a:hover {
color: #ff8855;
}
/* Projekt, Galerie */
#projektimg {
position: absolute;
z-index: 1;
top: 50%;
margin-top: -250px;
overflow-x: auto;
height: 510px;
float: left;
}
td {
vertical-align: top;
padding: 0;
margin: 0;
}
table, tbody {
padding: 0;
margin: 0;
}
tr {
margin: 0;
padding: 0;
}
/* Sticky */
.my-sticky-element {
position: absolute;
top: 50%;
margin-top: -250px;
overflow-x: auto;
height: 440px;
width: 210px;
background-color: #ff0000;
padding: 30px 30px 30px 30px;
float: left;
z-index: 5;
}
.my-sticky-element.fixed {
position: fixed;
left: 0;
z-index: 100;
}
ps:我是 javascript 的血腥初学者。