【发布时间】:2017-01-31 21:09:01
【问题描述】:
我正在尝试在单击a 类中的a 元素时进行平滑滚动。它正在重定向到对应的 id。但是平滑滚动不起作用。
index.php
<div class="panel">
<p><a href="gallary.php#singleclr_led">SINGLE COLOUR LED</a></p>
<p><a href="gallary.php#doubleclr_led">TWO COLOUR LED</a></p>
<p><a href="gallary.php#multiclr_led">MULTI COLOUR LED</a></p>
<p><a href="gallary.php#indoor_led">INDOOR LED DISPLAY</a></p>
<p><a href="gallary.php#outdoor_led">OUTDOOR LED DISPLAY</a></p>
</div>
jquery
$('.panel a').click(function(){
$('html, body').animate({
scrollTop: $( $(this).attr('href') ).offset().top
}, 500);
return false;
});
galary.php
<div class="col-md-6 col-xs-12 gallary-img1" id="multiclr_led">
<div class="hovereffect">
<img src="images/colorimg.jpg" class="img-responsive "alt="">
<div class="overlay">
<h2>MULTI COLOUR LED</h2>
<div class="hover-content">
<P>6 colors are possible like in addition to RGB, they are cyan, magenta & yellow. This property is well utilized by the motherboard manufacturer, to show the power indication, RED means lower power than the recommended rating, green means ambient power etc. So they compacted the space requirements.</P>
</div>
</div>
</div>
</div>
找不到问题。帮助这个问题。提前致谢。
【问题讨论】:
-
所以你在另一个页面(我们命名为
index.php),你想打开一个新页面(gallery.php),平滑滚动到对应的id? -
是的,你是对的@andreivictor
-
您能否告诉我们目标 HTML 的外观。是不是类似于
<div id="singleclr_led">...并且是仅在index.php或gallery.php中的面板? -
查看更新的问题@caramba