【发布时间】:2014-06-01 15:32:14
【问题描述】:
我需要一些 JavaScript 帮助!
我有两页。一个有图像缩略图,另一个页面有在水平滚动导航中放大的相同图像(这里的图像大小约为 600 像素高度)。
所以第一页(selected.html)看起来像这样:
<div class="thumbs">
<a href="work.html#1"><img src="images/1.jpg" height="170"></a>
<a href="work.html#2"><img src="images/2.jpg" height="170"></a>
<a href="work.html#3"><img src="images/3.jpg" height="170"></a>
<a href="work.html#4"><img src="images/4.jpg" height="170"></a>
<a href="work.html#5"><img src="images/5.jpg" height="170"></a>
<a href="work.html#6"><img src="images/6.jpg" height="170"></a>
<a href="work.html#7"><img src="images/7.jpg" height="170"></a>
<a href="work.html#8"><img src="images/8.jpg" height="170"></a>
</div>
第二页(work.html)看起来像这样:
<div class="images">
<a name="1"><img src="images/1.jpg"></a>
<a name="2"><img src="images/2.jpg"></a>
<a name="3"><img src="images/3.jpg"></a>
<a name="4"><img src="images/4.jpg"></a>
<a name="5"><img src="images/5.jpg"></a>
<a name="6"><img src="images/6.jpg"></a>
<a name="7"><img src="images/7.jpg"></a>
<a name="8"><img src="images/8.jpg"></a>
</div>
页面的css:
.thumbs {
margin-top: 60px;
margin-left:auto;
margin-right:auto;
text-align: center;}
.thumbs img {
padding: 10px 10px 10px 10px;}
.images {
white-space: nowrap; width: auto; margin-top: 25px; }
.images img {
padding: 0 50px 0 50px; margin: 50px 0 0 0; max-width: 100%; height: auto; width: auto\9; /* ie8 */ }
我的问题是...我需要什么代码,以便当我单击 selected.html 页面中的一个缩略图时,它会将我带到 work.html 页面并自动滚动到同一图像的锚 id(并在页面中水平居中)?我试过滚动到插件没有运气。
任何知道自己在做什么的人的帮助将不胜感激!
谢谢。
【问题讨论】:
标签: jquery scroll anchor scrollto