我试图让单个链接滚动到两个不同溢出的 div 中的两个不同点。
这是一个稍微有效的jsfiddle ,它可能更清楚地解释了我正在尝试做的事情。
HTML
<div id="small-box-links">
<a href="#small-box1">Link to small-box #1 and #5</a>
<a href="#small-box2">Link to small-box #2 and #4</a>
<a href="#small-box3">Link to small-box #3 and #6</a>
</div>
<div id="small-box-container">
<div id="small-box1" class="small-box">Small-Box #1</div>
<div id="small-box2" class="small-box">Small-Box #2</div>
<div id="small-box3" class="small-box">Small-Box #3</div>
</div>
<div id="small-box-container2">
<div id="small-box4" class="small-box">Small-Box #4</div>
<div id="small-box5" class="small-box">Small-Box #5</div>
<div id="small-box6" class="small-box">Small-Box #6</div>
</div>
JS
$(document).ready(function()
{
// Scroll the content inside the #scroll-container div
$('#small-box-links').localScroll({
target:'#small-box-container'
});
$('#small-box-links').localScroll({
target:'#small-box-container2'
});
});
CSS
#small-box-container {
border: 1px solid black;
padding: 20px;
width: 300px;
height: 200px;
overflow: scroll;
}
#small-box-container2 {
border: 1px solid black;
padding: 20px;
width: 300px;
height: 200px;
overflow: scroll;
}
.small-box {
color: #fff;
padding: 10px;
width: 200px;
height: 200px;
margin: 0 0 50px 0;
}
#small-box1 {
background: blue;
}
#small-box2 {
background: red;
}
#small-box3 {
background: green;
}
#small-box4 {
background: orange;
}
#small-box5 {
background: purple;
}
#small-box6 {
background: yellow;
}
如果有人问过这个问题,请提前抱歉,我的搜索没有结果。
谢谢!