CSS3 或 JavaScript 滑块他们是怎么做到的?
我正在开发一个新网站,想了解 Apple 和 IBM 如何在他们的网站上制作滑块。
示例: http://www.ibm.com/us/en/sandbox/ver2/和 http://www.apple.com/imac/
注意文本和图像反向滑动的方式方向。看来他们是用 CSS3 来做的,但我不知道他们如何获得下面按钮的 onclick,在不交换类的情况下工作。
任何人都可以提供一些见解吗?
I am working on a new site and wanted to figure out how Apple and IBM did a slider on their website.
Examples:
http://www.ibm.com/us/en/sandbox/ver2/ and
http://www.apple.com/imac/
Notice the way the text and images slide in opposite directions. It appears they do it with CSS3, yet I can't figure out how they get the onclick of the buttons below, to work without swapping out classes.
Can anyone provide some insight?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
具体来说,看看苹果的滑块,有几件事发生了。
他们使用 JS 来挂钩点击事件,当他们这样做时,他们正在更改
上的属性,这反过来又更改了 CSS,CSS 使用 CSS3 过渡提供了动画。
看一下代码:
这是 HTML 代码的片段。您可以看到
exited
和entered
属性。这些是在需要新部分时使用 javascript 进行的更改(通过 onclick)然后,查看 CSS (http://images.apple.com/global/styles/productbrowser.css),我们看到许多 CSS3 转换/转换属性和样式
提供了一个小片段,您可以看到不同的
entered
或exited
属性值如何影响变换,反过来又通过过渡进行动画处理。他们缩小了 JS,所以我无法真正向您展示它是如何工作的,但它并不太复杂。
我希望这是有道理的并且有帮助:)
Specifically looking at the Apple slider there is a couple of things going on.
They are using JS to hook into the click event and when they do that, they are changing an attribute on the
<ul>
, this in-turn changes the CSS, which, using CSS3 transitions, provides the animation.So having a look into the code:
Here is a snippet of the HTML code. You can see the
exited
andentered
attributes. These are changes using javascript when a new section is required (via the onclick)Then, looking into the CSS (http://images.apple.com/global/styles/productbrowser.css), we see a number of CSS3 transition/transforms properties and styles
a small snippet is provided, you can see how the different
entered
orexited
attribute values effect the transforms, which in turn are animated by the transitions.They minified the JS so I can't really show you how thats working, but it's not too complex.
I hope this make sense and is helpful :)
互联网上有许多可用的 JQuery javascript,因此您可以使用它来实现这种类型的滑块。 JQuery 有很多这样的东西。
您还可以使用 javascript 文件获取此类内容。
您可以访问菜单和动态驾驶导航以获取更多信息。您还可以获取来源,通过该来源可以找到您正在搜索的内容。
There are many JQuery javascripts available on internet so you can implement this type of slider using it. And ya JQuery has plenty of them.
You can also acquire this type of thing using javascript files.
You can visit Menus & Navigation of Dynamic Drive for more information. You can also get the source by which you can find out the thing you are searching for..