首页 > 软件开发 > JQUERY >

html+css3+jquery垂直渐隐显示多级下拉特效

来源:互联网 2023-03-16 23:54:31 版权归原作者所有,如有侵权,请联系我们

html css3 jquery垂直渐隐显示多级下拉特效nGh办公区 - 实用经验教程分享!

工具/原料

  • adobe dreamweaver

方法/步骤

  • 1

    新建html文档。nGh办公区 - 实用经验教程分享!

    html css3 jquery垂直渐隐显示多级下拉特效nGh办公区 - 实用经验教程分享!

  • 2

    书写hmtl代码。nGh办公区 - 实用经验教程分享!

    ul class="cd-accordion-menu animated">nGh办公区 - 实用经验教程分享!

    li class="has-children">nGh办公区 - 实用经验教程分享!

    input type="checkbox" name ="group-1" id="group-1" checked>nGh办公区 - 实用经验教程分享!

    label for="group-1">Group 1/label>nGh办公区 - 实用经验教程分享!

    ul>nGh办公区 - 实用经验教程分享!

    li class="has-children">nGh办公区 - 实用经验教程分享!

    input type="checkbox" name ="sub-group-1" id="sub-group-1">nGh办公区 - 实用经验教程分享!

    label for="sub-group-1">Sub Group 1/label>nGh办公区 - 实用经验教程分享!

    ul>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    /ul>nGh办公区 - 实用经验教程分享!

    /li>nGh办公区 - 实用经验教程分享!

    li class="has-children">nGh办公区 - 实用经验教程分享!

    input type="checkbox" name ="sub-group-2" id="sub-group-2">nGh办公区 - 实用经验教程分享!

    label for="sub-group-2">Sub Group 2/label>nGh办公区 - 实用经验教程分享!

    ul>nGh办公区 - 实用经验教程分享!

    li class="has-children">nGh办公区 - 实用经验教程分享!

    input type="checkbox" name ="sub-group-level-3" id="sub-group-level-3">nGh办公区 - 实用经验教程分享!

    label for="sub-group-level-3">Sub Group Level 3/label>nGh办公区 - 实用经验教程分享!

    ul>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    /ul>nGh办公区 - 实用经验教程分享!

    /li>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    /ul>nGh办公区 - 实用经验教程分享!

    /li>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    /ul>nGh办公区 - 实用经验教程分享!

    /li>nGh办公区 - 实用经验教程分享!

    li class="has-children">nGh办公区 - 实用经验教程分享!

    input type="checkbox" name ="group-2" id="group-2">nGh办公区 - 实用经验教程分享!

    label for="group-2">Group 2/label>nGh办公区 - 实用经验教程分享!

    ul>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    /ul>nGh办公区 - 实用经验教程分享!

    /li>nGh办公区 - 实用经验教程分享!

    li class="has-children">nGh办公区 - 实用经验教程分享!

    input type="checkbox" name ="group-3" id="group-3">nGh办公区 - 实用经验教程分享!

    label for="group-3">Group 3/label>nGh办公区 - 实用经验教程分享!

    ul>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    /ul>nGh办公区 - 实用经验教程分享!

    /li>nGh办公区 - 实用经验教程分享!

    li class="has-children">nGh办公区 - 实用经验教程分享!

    input type="checkbox" name ="group-4" id="group-4">nGh办公区 - 实用经验教程分享!

    label for="group-4">Group 4/label>nGh办公区 - 实用经验教程分享!

    ul>nGh办公区 - 实用经验教程分享!

    li class="has-children">nGh办公区 - 实用经验教程分享!

    input type="checkbox" name ="sub-group-3" id="sub-group-3">nGh办公区 - 实用经验教程分享!

    label for="sub-group-3">Sub Group 3/label>nGh办公区 - 实用经验教程分享!

    ul>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    /ul>nGh办公区 - 实用经验教程分享!

    /li>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    li>a href="#0">Image/a>/li>nGh办公区 - 实用经验教程分享!

    /ul>nGh办公区 - 实用经验教程分享!

    /li>nGh办公区 - 实用经验教程分享!

    /ul>nGh办公区 - 实用经验教程分享!

    html css3 jquery垂直渐隐显示多级下拉特效nGh办公区 - 实用经验教程分享!

  • 2相关内容未经授权抓取自百度经验
  • 3

    初始化css代码。nGh办公区 - 实用经验教程分享!

    style>nGh办公区 - 实用经验教程分享!

    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-size: 100%; font: inherit; vertical-align: baseline; }nGh办公区 - 实用经验教程分享!

    article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section, main { display: block; }nGh办公区 - 实用经验教程分享!

    body { line-height: 1; }nGh办公区 - 实用经验教程分享!

    ol, ul { list-style: none; }nGh办公区 - 实用经验教程分享!

    blockquote, q { quotes: none; }nGh办公区 - 实用经验教程分享!

    blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; }nGh办公区 - 实用经验教程分享!

    table { border-collapse: collapse; border-spacing: 0; }/style>nGh办公区 - 实用经验教程分享!

    html css3 jquery垂直渐隐显示多级下拉特效nGh办公区 - 实用经验教程分享!

  • 4

    书写css代码。nGh办公区 - 实用经验教程分享!

    *, *::after, *::before { box-sizing: border-box; }nGh办公区 - 实用经验教程分享!

    html { font-size: 62.5%; }nGh办公区 - 实用经验教程分享!

    body { font-size: 1.6rem; font-family: "Jaldi", sans-serif; color: #ffffff; background-color: #a0f6aa; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }nGh办公区 - 实用经验教程分享!

    a { color: #a0f6aa; text-decoration: none; }nGh办公区 - 实用经验教程分享!

    h1 { text-align: center; width: 90%; margin: 2em auto 0; font-size: 2.4rem; color: #507b55; font-weight: bold; }nGh办公区 - 实用经验教程分享!

    @media only screen and (min-width: 600px) {nGh办公区 - 实用经验教程分享!

    h1 { font-size: 3.2rem; }nGh办公区 - 实用经验教程分享!

    }nGh办公区 - 实用经验教程分享!

    input { font-family: "Jaldi", sans-serif; font-size: 1.6rem; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu { width: 90%; max-width: 600px; background: #4d5158; margin: 4em auto; box-shadow: 0 4px 40px #70ac76; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul { display: none; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu li { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu input[type=checkbox] { position: absolute; opacity: 0; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu label, .cd-accordion-menu a { position: relative; display: block; padding: 18px 18px 18px 64px; background: #4d5158; box-shadow: inset 0 -1px #555960; color: #ffffff; font-size: 1.6rem; }nGh办公区 - 实用经验教程分享!

    .no-touch .cd-accordion-menu label:hover, .no-touch .cd-accordion-menu a:hover { background: #52565d; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu label::before, .cd-accordion-menu label::after, .cd-accordion-menu a::after { content: ''; display: inline-block; width: 16px; height: 16px; position: absolute; top: 50%; -webkit-transform: translateY(-50%); -moz-transform: translateY(-50%); -ms-transform: translateY(-50%); -o-transform: translateY(-50%); transform: translateY(-50%); }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu label { cursor: pointer; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu label::before, .cd-accordion-menu label::after { background-image: url(../img/cd-icons.svg); background-repeat: no-repeat; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu label::before { left: 18px; background-position: 0 0; -webkit-transform: translateY(-50%) rotate(-90deg); -moz-transform: translateY(-50%) rotate(-90deg); -ms-transform: translateY(-50%) rotate(-90deg); -o-transform: translateY(-50%) rotate(-90deg); transform: translateY(-50%) rotate(-90deg); }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu label::after { left: 41px; background-position: -16px 0; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu a::after { left: 36px; background: url(../img/cd-icons.svg) no-repeat -48px 0; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu input[type=checkbox]:checked label::before { -webkit-transform: translateY(-50%); -moz-transform: translateY(-50%); -ms-transform: translateY(-50%); -o-transform: translateY(-50%); transform: translateY(-50%); }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu input[type=checkbox]:checked label::after { background-position: -32px 0; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu input[type=checkbox]:checked label ul, .cd-accordion-menu input[type=checkbox]:checked label:nth-of-type(n) ul { display: block; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul label, .cd-accordion-menu ul a { background: #35383d; box-shadow: inset 0 -1px #41444a; padding-left: 82px; }nGh办公区 - 实用经验教程分享!

    .no-touch .cd-accordion-menu ul label:hover, .no-touch .cd-accordion-menu ul a:hover { background: #3c3f45; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu > li:last-of-type > label, .cd-accordion-menu > li:last-of-type > a, .cd-accordion-menu > li > ul > li:last-of-type label, .cd-accordion-menu > li > ul > li:last-of-type a { box-shadow: none; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul label::before { left: 36px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul label::after, .cd-accordion-menu ul a::after { left: 59px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul ul label, .cd-accordion-menu ul ul a { padding-left: 100px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul ul label::before { left: 54px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul ul label::after, .cd-accordion-menu ul ul a::after { left: 77px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul ul ul label, .cd-accordion-menu ul ul ul a { padding-left: 118px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul ul ul label::before { left: 72px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul ul ul label::after, .cd-accordion-menu ul ul ul a::after { left: 95px; }nGh办公区 - 实用经验教程分享!

    @media only screen and (min-width: 600px) {nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu label, .cd-accordion-menu a { padding: 24px 24px 24px 82px; font-size: 1.9rem; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu label::before { left: 24px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu label::after { left: 53px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul label, .cd-accordion-menu ul a { padding-left: 106px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul label::before { left: 48px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul label::after, .cd-accordion-menu ul a::after { left: 77px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul ul label, .cd-accordion-menu ul ul a { padding-left: 130px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul ul label::before { left: 72px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul ul label::after, .cd-accordion-menu ul ul a::after { left: 101px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul ul ul label, .cd-accordion-menu ul ul ul a { padding-left: 154px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul ul ul label::before { left: 96px; }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu ul ul ul label::after, .cd-accordion-menu ul ul ul a::after { left: 125px; }nGh办公区 - 实用经验教程分享!

    }nGh办公区 - 实用经验教程分享!

    .cd-accordion-menu.animated label::before { -webkit-transition: -webkit-transform 0.3s; -moz-transition: -moz-transform 0.3s; transition: transform 0.3s; }nGh办公区 - 实用经验教程分享!

    html css3 jquery垂直渐隐显示多级下拉特效nGh办公区 - 实用经验教程分享!

  • 5

    书写并添加js代码。nGh办公区 - 实用经验教程分享!

    script src="js/modernizr.js">/script>nGh办公区 - 实用经验教程分享!

    script src="js/jquery-2.1.1.min.js">/script>nGh办公区 - 实用经验教程分享!

    script>nGh办公区 - 实用经验教程分享!

    jQuery(document).ready(function(){nGh办公区 - 实用经验教程分享!

    var accordionsMenu = $('.cd-accordion-menu');nGh办公区 - 实用经验教程分享!

    nGh办公区 - 实用经验教程分享!

    if( accordionsMenu.length > 0 ) {nGh办公区 - 实用经验教程分享!

    nGh办公区 - 实用经验教程分享!

    accordionsMenu.each(function(){nGh办公区 - 实用经验教程分享!

    var accordion = $(this);nGh办公区 - 实用经验教程分享!

    accordion.on('change', 'input[type="checkbox"]', function(){nGh办公区 - 实用经验教程分享!

    var checkbox = $(this);nGh办公区 - 实用经验教程分享!

    console.log(checkbox.prop('checked'));nGh办公区 - 实用经验教程分享!

    ( checkbox.prop('checked') ) ? checkbox.siblings('ul').attr('style', 'display:none;').slideDown(300) : checkbox.siblings('ul').attr('style', 'display:block;').slideUp(300);nGh办公区 - 实用经验教程分享!

    });nGh办公区 - 实用经验教程分享!

    });nGh办公区 - 实用经验教程分享!

    }nGh办公区 - 实用经验教程分享!

    });/script>nGh办公区 - 实用经验教程分享!

    html css3 jquery垂直渐隐显示多级下拉特效nGh办公区 - 实用经验教程分享!

  • 6

    代码整体结构。nGh办公区 - 实用经验教程分享!

    html css3 jquery垂直渐隐显示多级下拉特效nGh办公区 - 实用经验教程分享!

  • 7

    查看效果。nGh办公区 - 实用经验教程分享!

    html css3 jquery垂直渐隐显示多级下拉特效nGh办公区 - 实用经验教程分享!

  • 注意事项

    • modernizr.js是个js包,可以网上下载。
    • jquery-2.1.1.min.js是个js包,可以网上下载。

    以上方法由办公区教程网编辑摘抄自百度经验可供大家参考!nGh办公区 - 实用经验教程分享!


    标签: CSSHTMLJQUERY

    办公区 Copyright © 2016-2023 www.bgqu.net. Some Rights Reserved. 备案号:湘ICP备2020019561号