使用 jQuery & CSS3 实现优雅的手风琴效果
手风琴效果常用于切换显示一组内容,这种方式既可以节省网页空间又可以有动画效果。今天,我们将创造一个优雅的手风琴内容效果。这个想法是有悬停时滑出一些垂直手风琴标签。我们将添加一些 CSS3 属性来提升外观。
HTML示例代码:
1 2 3 4 5 6 7 8 9 10 11 | <ul class ="accordion" id="accordion"> <li class ="bg1"> < div class ="heading">Heading</ div > < div class ="bgDescription"></ div > < div class ="description"> <h2>Heading</h2> <p>Some descriptive text</p> <a href="#">more ?</a> </ div > </li> </ul> |
CSS示例代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ul.accordion li .description h 2 { text-transform : uppercase ; font-style : normal ; font-weight : bold ; letter-spacing : 1px ; font-size : 45px ; color : #444 ; text-align : left ; margin : 0px 0px 15px 20px ; text-shadow : -1px -1px 1px #ccc ; } ul.accordion li .description p{ line-height : 14px ; margin : 10px 22px ; font-family : "Trebuchet MS" , sans-serif ; font-size : 12px ; font-style : italic ; font-weight : normal ; text-transform : none ; letter-spacing : normal ; line-height : 1.6em ; } ul.accordion li .description a{ position : absolute ; bottom : 5px ; left : 20px ; text-transform : uppercase ; font-style : normal ; font-size : 11px ; text-decoration : none ; color : #888 ; } ul.accordion li .description a:hover{ color : #333 ; text-decoration : underline ; } |
JavaScript代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | $( function () { $( '#accordion > li' ).hover( function () { var $ this = $( this ); $ this .stop().animate({ 'width' : '480px' },500); $( '.heading' ,$ this ).stop( true , true ).fadeOut(); $( '.bgDescription' ,$ this ).stop( true , true ).slideDown(500); $( '.description' ,$ this ).stop( true , true ).fadeIn(); }, function () { var $ this = $( this ); $ this .stop().animate({ 'width' : '115px' },1000); $( '.heading' ,$ this ).stop( true , true ).fadeIn(); $( '.description' ,$ this ).stop( true , true ).fadeOut(500); $( '.bgDescription' ,$ this ).stop( true , true ).slideUp(700); } ); }); |
您可能感兴趣的相关文章
作者:山边小溪
主站:yyyweb.com 记住啦:)
欢迎任何形式的转载,但请务必注明出处。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
2013-11-06 设计宝库:22套精美的 PhotoShop 素材免费下载
2013-11-06 酷站欣赏:12个漂亮的国外单页网站设计案例
2013-11-06 值得 Web 开发人员收藏的16款 HTML5 工具
2013-11-06 Node.js Web 开发框架大全《静态文件服务器篇》
2012-11-06 Web前端开发人员和设计师必读文章【系列十一】
2011-11-06 分享12款非常漂亮的免费国外网站模板