“之前和之后”交互式图像蒙版
我想使用 web-kit 重新创建最近在 Guardian.co.uk 上展示的前后图像滑块。
它基本上是两个图像叠放在一起,带有垂直滑块它跟随鼠标,在左侧显示一张图像,在右侧显示另一张图像。
I'd like to recreate the before and after image slider recently featured on the guardian.co.uk, using web-kit.
http://www.guardian.co.uk/uk/interactive/2011/aug/09/london-riots-before-after-photographs
It's basically two images on top of each other with a vertical slider that follows the mouse, revealing one image on the left and the other on the right.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我在此处提供了一个示例。它需要稍微扩展一下,但它显示了基本原理。它不使用 CSS3 的东西,因此,虽然不会因为使用 CSS3 而获得 GeekPoints(tm),但它可以在加载更多浏览器时工作。
HTML
jQuery
I've come up with an example here. It will need expanding a little, but it shows the basic principles. This doesn't use CSS3 stuff so, while not gaining GeekPoints(tm) for using CSS3, it'll work in loads more browsers.
HTML
jQuery
这是一个插件 http://www.catchmyfame.com/2009/06 /25/jquery-beforeafter-plugin/
here's a plugin http://www.catchmyfame.com/2009/06/25/jquery-beforeafter-plugin/
这是直接从监护人页面获取的代码:
正如您所看到的,它非常混乱。第一个参数是 jQuery 对象,第二个和第三个参数是之前/之后的 url。
Here's the code taken straight from the guardian page:
As you can see, it's quite a mess. The first argument is a jQuery object, and the second and third are before/after urls.
以防万一有人仍在寻找使用 webkit 和 CSS3 的解决方案 - 这里有一个演示。只需更改为“位置”即可。除了 Chrome 之外,这可能不起作用。
Just in case anybody is still looking for a solution using webkit and CSS3 -- there's a demo here. Just change to "Position". This might not work in anything but Chrome.
有趣的问题...
你为什么不使用原件?不需要jQuery!
监护人是Github上的“监护人”。他们知道该怎么做,所以这是开源的:
https://github.com/guardian/image-fader-slider
Funny question ...
Why don't you use the original? There is no need for jQuery!
The Guardian is 'guardian' on github. They know how to do it and so it is OpenSource:
https://github.com/guardian/image-fader-slider