基本 jQuery:单击一个按钮将文本面板滑出屏幕,单击另一个按钮将其滑回到屏幕上
我正在维护一个具有全屏背景照片和照片顶部的文本面板的网站。
这是我要添加的功能:
单击“隐藏文本”按钮会使文本面板在屏幕外显示动画,以便访问者可以看到整个背景照片。单击“隐藏文本”按钮后,应该淡出,另一个按钮“显示文本”在不同的位置淡入。单击“显示文本”按钮时,文本面板应从屏幕左侧动画回到正确的位置。同时,“显示文本”按钮应淡出,“隐藏文本”按钮应淡入。
换句话来说:
单击#hideText 时,
瞄准#mainPanel 离开屏幕,淡出#hideText,淡入#showText。
单击 #showText 时,
将 #mainPanel 从屏幕外的当前位置动画到屏幕上的正确位置,淡出 #showText,淡入 #hideText
有人可以告诉我如何使用 jQuery 执行此操作吗?我将非常感谢实际的代码。
I'm maintaining a website that has full screen background photos, and a text panel on top of the photos.
Here's the functionality I want to add:
Clicking "Hide text" button makes the text panel animate left off-screen, so that the visitors can see the whole background photo. The "Hide text" button, after being clicked, should fade out, and another button, "Show text" fades in in a different place. When "Show text" button is clicked, the text panel should animate from off-screen left back to its proper place. Simultaneously, "Show text" button should fades out, and "Hide text" button should fade in.
To rephrase it:
when #hideText is clicked,
aimate #mainPanel left off-screen, fade out #hideText, fade in #showText.
when #showText is clicked,
animate #mainPanel from its current position left off-screen to its proper place onscreen, fade out #showText, fade in #hideText
Could someone please show me how to do this with jQuery? I would be very grateful for actual code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://jsfiddle.net/dXSPa/
和 html(仅作为示例)
如果您不喜欢宽度效果可以很容易地修改为从屏幕左侧滑出,就像这样 http://jsfiddle.net/3FwWV/
ps:对于右侧的按钮 - 单击该按钮,而不是单击 jsfiddle 带有“Result”一词的跨度
http://jsfiddle.net/dXSPa/
and html (just for an example)
if you do not like the width effect it can be easily modified for the slide out of the left side of screen, like this http://jsfiddle.net/3FwWV/
ps: for the button on the right - click on the button, not on the jsfiddle's span with word 'Result'
http://jqueryui.com/demos/hide/
在这里查看幻灯片效果和实现。
http://jqueryui.com/demos/hide/
Check the slide effect and implementation here.