怎样安装Dreamweaver的jquery扩展,我们通常会用dreamweaver这个网页设计软件来编写网页前台代码,在编写代码时会经常出现下拉的菜单供我们选择,为我们编写代码节省了很多的时间。这样......
2023-03-17 342 JQUERY DREAMWEAVER
jQuery CSS3 HTML5折叠卡片式展开隐藏特效
新建html文档。
书写hmtl代码。
div class="container">
div class="card-drop">
a class='toggle' href="#">
i class='fa fa-suitcase'>/i>
span class='label-active'>百度经验/span>
/a>
ul>
li class='active'>
a data-label="Everyting" href="#">i class='fa fa-suitcase'>/i> 百度经验/a>
/li>
li>
a data-label="Design" href="#">i class='fa fa-magic'>/i> 百度经验特效/a>
/li>
li >
a data-label="UI-UX" href="#">i class='fa fa-bolt'>/i> 百度经验特效/a>
/li>
li>
a data-label="Print" href="#">i class='fa fa-tint'>/i> 百度经验特效/a>
/li>
li>
a data-label="Photography" href="#">i class='fa fa-camera-retro'>/i> 网页特效/a>
/li>
li>
a data-label="Photography" href="#">i class='fa fa-camera-retro'>/i> flash动画/a>
/li>
/ul>
/div>
/div>
初始化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>
书写css代码。
body { background-color: #ecf0f1; overflow: hidden; font-family: 'Roboto', sans-serif; font-size: 1em; }
.container { max-width: 800px; margin: 0 auto; padding: 0 15px; }
header { padding: 3.5rem 10%; background-color: #fff; margin-bottom: 2.5rem; text-align: center; }
header svg { max-width: 50px; display: inline-block; fill: #1abc9c; vertical-align: middle; }
header h1, header h2, header p { color: #2c3e50; margin-bottom: 1rem; }
header h1 { font-weight: 300; color: #1abc9c; letter-spacing: -0.2rem; font-size: 4rem; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8); }
header h2 { font-size: 1.5rem; margin-bottom: 0; }
header h2 span { font-weight: 300; display: inlie-block; padding: 0 8px; font-size: 80%; color: #fff; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; }
header h2 span.js { background-color: #E4A128; }
header h2 span.css { background-color: #0070BB; }
header h2 span.heart { background-color: #EB304A; }
p { line-height: 1.8; text-align: left; font-weight: 300; font-size: 1.2rem; }
.card-drop { position: relative; margin: 0 auto; -moz-perspective: 800px; -webkit-perspective: 800px; perspective: 800px; background: rgba(0, 0, 0, 0.1); }
.card-drop a { display: block; width: 100%; padding: 20px 0 20px 20px; height: 60px; text-decoration: none; color: #217dbb; background-color: #fafafa; border: 1px solid #ddd; -moz-transition: all 0.3s ease-out; -o-transition: all 0.3s ease-out; -webkit-transition: all 0.3s ease-out; transition: all 0.3s ease-out; }
.card-drop > a.toggle { position: relative; z-index: 100; -moz-backface-visibility: hidden; -webkit-backface-visibility: hidden; backface-visibility: hidden; -moz-transform-style: preserve-3d; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; -moz-transform-origin: 50% 0%; -ms-transform-origin: 50% 0%; -webkit-transform-origin: 50% 0%; transform-origin: 50% 0%; -moz-transition: linear 0.1s; -o-transition: linear 0.1s; -webkit-transition: linear 0.1s; transition: linear 0.1s; }
.card-drop > a.toggle:active { -moz-transform: rotateX(60deg); -webkit-transform: rotateX(60deg); transform: rotateX(60deg); }
.card-drop > a.toggle:active:after { -moz-transform: rotateX(180deg); -webkit-transform: rotateX(180deg); transform: rotateX(180deg); }
.card-drop > a.toggle:before, .card-drop > a.toggle:after { content: ""; position: absolute; }
.card-drop > a.toggle:before { right: 25px; top: 50%; margin-top: -2.5px; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 6px solid rgba(0, 0, 0, 0.8); }
.card-drop > a.toggle.active:before { transform: rotate(180deg); }
.card-drop ul { position: absolute; height: 100%; top: 0; display: block; width: 100%; }
.card-drop ul li { margin: 0 auto; -moz-transition: all, ease-out 0.3s; -o-transition: all, ease-out 0.3s; -webkit-transition: all, ease-out 0.3s; transition: all, ease-out 0.3s; position: absolute; top: 0; z-index: 0; width: 100%; }
.card-drop ul li a { border-top: none; }
.card-drop ul li a:hover { background-color: #4aa3df; color: #f3f9fd; }
.card-drop ul li.active a { color: #fff; background-color: #258cd1; cursor: default; }
.card-drop ul li.closed a:hover { cursor: default; background-color: #3498db; }
书写并添加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>
代码整体结构。
查看效果。
以上方法由办公区教程网编辑摘抄自百度经验可供大家参考!
相关文章
怎样安装Dreamweaver的jquery扩展,我们通常会用dreamweaver这个网页设计软件来编写网页前台代码,在编写代码时会经常出现下拉的菜单供我们选择,为我们编写代码节省了很多的时间。这样......
2023-03-17 342 JQUERY DREAMWEAVER
jQuery MiniUI 快速入门,前段时间由于工作的原因接触到MiiUI。感觉MiiUI很强大,使用起来也很舒服。下面我就带领大家快速的使用MiiUI。MiiUI-专业WeUI控件库它能缩短开发时......
2023-03-17 330 JQUERY
怎么使用JQuery Mobile开发移动网站,现在越来越多的人用网站来做手机a,这样的好处是,可以做一个网站,基本上可以做到多个平台adroid,io,w,都可以使用。这里使用JQueryMoile......
2023-03-17 374 JQUERY