如何使用类似于 Chart.io 和 simple.com 的 smoothscroll 窗格创建动画菜单

发布于 2024-12-21 19:27:34 字数 194 浏览 4 评论 0原文

我正在尝试创建一个 1 页网站,顶部有一个与 Chart.io 或 simple.com 类似风格的菜单,有人能给我指点一个好的教程吗?我已经使用谷歌进行了搜索,但我还没有找到任何可以实现我想要做的事情的东西。

我目前使用 Mootools 平滑滚动进行滚动,但是我在为菜单项下的元素设置动画时遇到问题。

非常感谢任何和所有的帮助......

I'm trying to create a 1 page website that has a menu across the top in a similar style to chart.io or simple.com, can anyone point me in the direction of a good tutorial? I've searched using google but I've not managed to come up with anything that does something like what I'm trying to do.

I currently have Mootools smooth scroll doing the scroll however I'm having trouble animating the element under the menu item.

Any and all help is greatly appreciated...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

当爱已成负担 2024-12-28 19:27:34

开始使用 CSS 固定标题菜单:

#header {
    position: fixed;
    top: 0;
    left: 0;
}

然后你可以使用像这样的 Mootools 插件:

http://davidwalsh.name/mootools-scrollspy
演示: http://davidwalsh.name/dw-content/scroll-spy .php?page=3

正如你所看到的,使用这个插件你可以轻松获取滚动位置,这样你就可以将菜单下的三角形放置在正确的位置。

要为三角形设置动画,您只需要一些基本的补间动画。 HTML 将会是这样的:

<div id="header">
    Your header here
    <div id="triangle">
        <img src="triangle.png" alt="">
    </div>
</div>

CSS:

#header #triangle {
    position: absolute;
    bottom: 0;
    left: 0;
}

Mootools tween 用于动画,这会将三角形从当前位置平滑地移动到左侧 300px:

$('triangle').tween('left', 300);

希望这会对您有所帮助!

Start making the header menu fixed using CSS:

#header {
    position: fixed;
    top: 0;
    left: 0;
}

Then you can use a Mootools plugin like this one:

http://davidwalsh.name/mootools-scrollspy
Demo: http://davidwalsh.name/dw-content/scroll-spy.php?page=3

As you can see, with this plugin you can easily get the scroll position, so you can place the triangle under the menu in the correct position.

To animate the triangle, you just need some basic tween animation. HTML will be something like this:

<div id="header">
    Your header here
    <div id="triangle">
        <img src="triangle.png" alt="">
    </div>
</div>

CSS:

#header #triangle {
    position: absolute;
    bottom: 0;
    left: 0;
}

Mootools tween for animation, this will move the triangle smoothly from it's current position to 300px from the left:

$('triangle').tween('left', 300);

Hope this will help you!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文