jQuery+CSS3+HTML5折叠卡片式展开隐藏特效

2025-05-04 21:36:22

1、新建html文档。

jQuery+CSS3+HTML5折叠卡片式展开隐藏特效

3、初始化css代码。<style>html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0; font: inherit; font-size: 100%; vertical-align: baseline; }html { line-height: 1; }ol, ul { list-style: none; }table { border-collapse: collapse; border-spacing: 0; }caption, th, td { text-align: left; font-weight: normal; vertical-align: middle; }q, blockquote { quotes: none; }q:before, q:after, blockquote:before, blockquote:after { content: ""; content: none; }a img { border: none; }article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary { display: block; }* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }</style>

jQuery+CSS3+HTML5折叠卡片式展开隐藏特效

5、书写并添加js代码。<script src="js/jquery-2.1.1.min.js"></script><script>(function ($) { var cards = $('.card-drop'), toggler = cards.find('.toggle'), links = cards.find('ul>li>a'), li = links.parent('li'), count = links.length, width = 100; li.each(function (i) { $(this).css('z-index', count - i); }); function setClosed() { li.each(function (index) { $(this).css('top', index * 4).css('width', width - index * 0.5 + '%').css('margin-left', index * 0.25 + '%'); }); li.addClass('closed'); toggler.removeClass('active'); } setClosed(); toggler.on('mousedown', function () { var $this = $(this); if ($this.is('.active')) { setClosed(); } else { $this.addClass('active'); li.removeClass('closed'); li.each(function (index) { $(this).css('top', 60 * (index + 1)).css('width', '100%').css('margin-left', '0px'); }); } }); links.on('click', function (e) { var $this = $(this), label = $this.data('label'); icon = $this.children('i').attr('class'); li.removeClass('active'); if ($this.parent('li').is('active')) { $this.parent('li').removeClass('active'); } else { $this.parent('li').addClass('active'); } toggler.children('span').text(label); toggler.children('i').removeClass().addClass(icon); setClosed(); e.preventDefault; });}(jQuery));</script>

jQuery+CSS3+HTML5折叠卡片式展开隐藏特效

7、查看效果。

jQuery+CSS3+HTML5折叠卡片式展开隐藏特效
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢