我正在尝试根据这篇文章制作一个下拉菜单: http://www.queness.com/post/356/create-a-vertical-horizontal-and-diagonal-sliding-content-website-with-jquery
上面的示例显示了如何在单个页面上制作下拉页面。
现在,例如我有多个页面如下:
的index.php
about.php
contact.php
问题:是否可以在上面的多个/三个页面上下载内容?
CMIIW
答案 0 :(得分:0)
为了使网站以您希望的方式运行,您需要从每个页面中获取内容并将它们作为部分放在index.php页面上。每个部分都有一个唯一的ID,如下所示:
<div class="section about" id="about">
-- about.php content goes here
</div>
<div class="section contact" id="contact">
-- contact.php page content goes here --
</div>
然后在你的jquery中输入以下代码:
// Jump to target function
$('a[href^="#"]').on('click',function (e) {
var href = $(this).attr('href');
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 900, 'swing', function () {
window.location.hash = target;
});
});
在导航中,您将链接设为
<a href="#about">About Us</a>
当您点击该链接转到该页面的该部分时,您将看到滚动效果。