首页 > 软件开发 > JQUERY >

html5+css3+jquery网页顶部3D翻转展开导航

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

html5 css3 jquery网页顶部3D翻转展开导航LXm办公区 - 实用经验教程分享!

工具/原料

  • adobe dreamweaver

方法/步骤

  • 1

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

    html5 css3 jquery网页顶部3D翻转展开导航LXm办公区 - 实用经验教程分享!

  • 2

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

    header class="cd-header">LXm办公区 - 实用经验教程分享!

    a href="#0" class="cd-logo">img src="img/cd-logo.svg" alt="Logo">/a>LXm办公区 - 实用经验教程分享!

    a href="#0" class="cd-3d-nav-trigger">LXm办公区 - 实用经验教程分享!

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

    span>/span>LXm办公区 - 实用经验教程分享!

    /a>LXm办公区 - 实用经验教程分享!

    /header>LXm办公区 - 实用经验教程分享!

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

    main>LXm办公区 - 实用经验教程分享!

    h1>3D Rotating Navigation/h1>LXm办公区 - 实用经验教程分享!

    /main>LXm办公区 - 实用经验教程分享!

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

    nav class="cd-3d-nav-container">LXm办公区 - 实用经验教程分享!

    ul class="cd-3d-nav">LXm办公区 - 实用经验教程分享!

    li class="cd-selected">LXm办公区 - 实用经验教程分享!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /ul> !-- .cd-3d-nav -->LXm办公区 - 实用经验教程分享!

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

    span class="cd-marker color-1">/span>LXm办公区 - 实用经验教程分享!

    /nav> !-- .cd-3d-nav-container -->LXm办公区 - 实用经验教程分享!

    html5 css3 jquery网页顶部3D翻转展开导航LXm办公区 - 实用经验教程分享!

  • 2相关内容非法爬取自百度经验
  • 3

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

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

    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; }LXm办公区 - 实用经验教程分享!

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

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

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

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

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

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

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

    html5 css3 jquery网页顶部3D翻转展开导航LXm办公区 - 实用经验教程分享!

  • 4

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

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

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

    body { font-size: 1.6rem; font-family: "Open Sans", sans-serif; background-color: #485274; }LXm办公区 - 实用经验教程分享!

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

    .cd-header { height: 80px; width: 90%; margin: 0 auto; -webkit-transition: -webkit-transform 0.5s; -moz-transition: -moz-transform 0.5s; transition: transform 0.5s; -webkit-transform: translateZ(0); -moz-transform: translateZ(0); -ms-transform: translateZ(0); -o-transform: translateZ(0); transform: translateZ(0); -webkit-backface-visibility: hidden; backface-visibility: hidden; }LXm办公区 - 实用经验教程分享!

    .cd-header:after { content: ""; display: table; clear: both; }LXm办公区 - 实用经验教程分享!

    .cd-header.nav-is-visible { -webkit-transform: translateY(80px); -moz-transform: translateY(80px); -ms-transform: translateY(80px); -o-transform: translateY(80px); transform: translateY(80px); }LXm办公区 - 实用经验教程分享!

    .cd-logo { float: left; margin-top: 28px; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav-trigger { position: relative; float: right; height: 45px; width: 45px; margin-top: 18px; overflow: hidden; text-indent: 100%; white-space: nowrap; color: transparent; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav-trigger span, .cd-3d-nav-trigger span::before, .cd-3d-nav-trigger span::after { position: absolute; width: 28px; height: 3px; background-color: #FFF; -webkit-backface-visibility: hidden; backface-visibility: hidden; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav-trigger span { top: 21px; left: 8px; -webkit-transition: background 0.2s 0.5s; -moz-transition: background 0.2s 0.5s; transition: background 0.2s 0.5s; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav-trigger span::before, .cd-3d-nav-trigger span:after { content: ''; left: 0; -webkit-transition: -webkit-transform 0.2s 0.5s; -moz-transition: -moz-transform 0.2s 0.5s; transition: transform 0.2s 0.5s; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav-trigger span::before { bottom: 8px; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav-trigger span::after { top: 8px; }LXm办公区 - 实用经验教程分享!

    .nav-is-visible .cd-3d-nav-trigger span { background-color: rgba(255, 255, 255, 0); }LXm办公区 - 实用经验教程分享!

    .nav-is-visible .cd-3d-nav-trigger span::before, .nav-is-visible .cd-3d-nav-trigger span::after { background-color: white; }LXm办公区 - 实用经验教程分享!

    .nav-is-visible .cd-3d-nav-trigger span::before { -webkit-transform: translateY(8px) rotate(-45deg); -moz-transform: translateY(8px) rotate(-45deg); -ms-transform: translateY(8px) rotate(-45deg); -o-transform: translateY(8px) rotate(-45deg); transform: translateY(8px) rotate(-45deg); }LXm办公区 - 实用经验教程分享!

    .nav-is-visible .cd-3d-nav-trigger span::after { -webkit-transform: translateY(-8px) rotate(45deg); -moz-transform: translateY(-8px) rotate(45deg); -ms-transform: translateY(-8px) rotate(45deg); -o-transform: translateY(-8px) rotate(45deg); transform: translateY(-8px) rotate(45deg); }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav-container { position: fixed; top: 0; left: 0; height: 80px; width: 100%; background-color: #000000; visibility: hidden; -webkit-perspective: 1000px; -moz-perspective: 1000px; perspective: 1000px; -webkit-transform: translateY(-100%); -moz-transform: translateY(-100%); -ms-transform: translateY(-100%); -o-transform: translateY(-100%); transform: translateY(-100%); -webkit-transition: -webkit-transform 0.5s 0s, visibility 0s 0.5s; -moz-transition: -moz-transform 0.5s 0s, visibility 0s 0.5s; transition: transform 0.5s 0s, visibility 0s 0.5s; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav-container.nav-is-visible { visibility: visible; -webkit-transform: translateY(0); -moz-transform: translateY(0); -ms-transform: translateY(0); -o-transform: translateY(0); transform: translateY(0); -webkit-transition: -webkit-transform 0.5s 0s, visibility 0.5s 0s; -moz-transition: -moz-transform 0.5s 0s, visibility 0.5s 0s; transition: transform 0.5s 0s, visibility 0.5s 0s; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav { position: relative; height: 100%; background-color: #343c55; transform: translateZ(0); backface-visibility: hidden; transform: rotateX(90deg); transition: transform 0.5s; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav::after { content: ''; position: absolute; top: 0; left: 0; height: 100%; width: 100%; background-color: #000000; opacity: 1; visibility: visible; -webkit-transition: opacity 0.5s 0s, visibility 0.5s 0s; -moz-transition: opacity 0.5s 0s, visibility 0.5s 0s; transition: opacity 0.5s 0s, visibility 0.5s 0s; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav li { height: 100%; width: 20%; float: left; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav li:first-of-type a::before { background-image: url(../img/icon-1.svg); }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav li:nth-of-type(2) a::before { background-image: url(../img/icon-2.svg); }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav li:nth-of-type(3) a::before { background-image: url(../img/icon-3.svg); }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav li:nth-of-type(4) a::before { background-image: url(../img/icon-4.svg); }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav li:nth-of-type(5) a::before { background-image: url(../img/icon-5.svg); }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav a { position: relative; display: block; height: 100%; color: transparent; -webkit-transition: background-color 0.2s; -moz-transition: background-color 0.2s; transition: background-color 0.2s; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav a::before { content: ''; height: 32px; width: 32px; position: absolute; left: 50%; top: 50%; bottom: auto; right: auto; -webkit-transform: translateX(-50%) translateY(-50%); -moz-transform: translateX(-50%) translateY(-50%); -ms-transform: translateX(-50%) translateY(-50%); -o-transform: translateX(-50%) translateY(-50%); transform: translateX(-50%) translateY(-50%); background-size: 32px 64px; background-repeat: no-repeat; background-position: 0 0; }LXm办公区 - 实用经验教程分享!

    .no-touch .cd-3d-nav a:hover { background-color: #2b3145; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav .cd-selected a { background-color: #212635; }LXm办公区 - 实用经验教程分享!

    .no-touch .cd-3d-nav .cd-selected a:hover { background-color: #212635; }LXm办公区 - 实用经验教程分享!

    .cd-3d-nav .cd-selected a::before { background-position: 0 -32px; }LXm办公区 - 实用经验教程分享!

    .nav-is-visible .cd-3d-nav { -webkit-transform: translateZ(0); -moz-transform: translateZ(0); -ms-transform: translateZ(0); -o-transform: translateZ(0); transform: translateZ(0); }LXm办公区 - 实用经验教程分享!

    .nav-is-visible .cd-3d-nav::after { opacity: 0; visibility: hidden; -webkit-transition: opacity 0.5s 0s, visibility 0s 0.5s; -moz-transition: opacity 0.5s 0s, visibility 0s 0.5s; transition: opacity 0.5s 0s, visibility 0s 0.5s; }LXm办公区 - 实用经验教程分享!

    .cd-marker { position: absolute; bottom: 0; left: 0; height: 3px; width: 20%; background-color: currentColor; -webkit-transform-origin: center bottom; -moz-transform-origin: center bottom; -ms-transform-origin: center bottom; -o-transform-origin: center bottom; transform-origin: center bottom; -webkit-transform: translateZ(0) rotateX(90deg); -moz-transform: translateZ(0) rotateX(90deg); -ms-transform: translateZ(0) rotateX(90deg); -o-transform: translateZ(0) rotateX(90deg); transform: translateZ(0) rotateX(90deg); -webkit-transition: -webkit-transform 0.5s, left 0.5s, color 0.5s, background-color 0.5s; -moz-transition: -moz-transform 0.5s, left 0.5s, color 0.5s, background-color 0.5s; transition: transform 0.5s, left 0.5s, color 0.5s, background-color 0.5s; }LXm办公区 - 实用经验教程分享!

    .cd-marker::before { content: ''; position: absolute; bottom: 3px; left: 50%; right: auto; -webkit-transform: translateX(-50%); -moz-transform: translateX(-50%); -ms-transform: translateX(-50%); -o-transform: translateX(-50%); transform: translateX(-50%); height: 0; width: 0; border: 10px solid transparent; border-bottom-color: inherit; }LXm办公区 - 实用经验教程分享!

    .nav-is-visible .cd-marker { -webkit-transform: translateZ(0); -moz-transform: translateZ(0); -ms-transform: translateZ(0); -o-transform: translateZ(0); transform: translateZ(0); }LXm办公区 - 实用经验教程分享!

    .color-1 { color: #9a57bd; }LXm办公区 - 实用经验教程分享!

    .color-2 { color: #c96aa4; }LXm办公区 - 实用经验教程分享!

    .color-3 { color: #d6915e; }LXm办公区 - 实用经验教程分享!

    .color-4 { color: #5397c7; }LXm办公区 - 实用经验教程分享!

    .color-5 { color: #77cd91; }LXm办公区 - 实用经验教程分享!

    main { -webkit-transition: -webkit-transform 0.5s; -moz-transition: -moz-transform 0.5s; transition: transform 0.5s; -webkit-transform: translateZ(0); -moz-transform: translateZ(0); -ms-transform: translateZ(0); -o-transform: translateZ(0); transform: translateZ(0); -webkit-backface-visibility: hidden; backface-visibility: hidden; }LXm办公区 - 实用经验教程分享!

    main h1 { text-align: center; font-size: 2.4rem; font-weight: 300; color: #ffffff; margin: 2em auto; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }LXm办公区 - 实用经验教程分享!

    main.nav-is-visible { -webkit-transform: translateY(80px); -moz-transform: translateY(80px); -ms-transform: translateY(80px); -o-transform: translateY(80px); transform: translateY(80px); }LXm办公区 - 实用经验教程分享!

    html5 css3 jquery网页顶部3D翻转展开导航LXm办公区 - 实用经验教程分享!

  • 5

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

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

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

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

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

    $('.cd-3d-nav-trigger').on('click', function(){LXm办公区 - 实用经验教程分享!

    toggle3dBlock(!$('.cd-header').hasClass('nav-is-visible'));LXm办公区 - 实用经验教程分享!

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

    $('.cd-3d-nav a').on('click', function(){LXm办公区 - 实用经验教程分享!

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

    selected.parent('li').addClass('cd-selected').siblings('li').removeClass('cd-selected');LXm办公区 - 实用经验教程分享!

    updateSelectedNav('close');LXm办公区 - 实用经验教程分享!

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

    $(window).on('resize', function(){LXm办公区 - 实用经验教程分享!

    window.requestAnimationFrame(updateSelectedNav);LXm办公区 - 实用经验教程分享!

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

    function toggle3dBlock(addOrRemove) {LXm办公区 - 实用经验教程分享!

    if(typeof(addOrRemove)==='undefined') addOrRemove = true;LXm办公区 - 实用经验教程分享!

    $('.cd-header').toggleClass('nav-is-visible', addOrRemove);LXm办公区 - 实用经验教程分享!

    $('main').toggleClass('nav-is-visible', addOrRemove);LXm办公区 - 实用经验教程分享!

    $('.cd-3d-nav-container').toggleClass('nav-is-visible', addOrRemove);LXm办公区 - 实用经验教程分享!

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

    function updateSelectedNav(type) {LXm办公区 - 实用经验教程分享!

    var selectedItem = $('.cd-selected'),LXm办公区 - 实用经验教程分享!

    selectedItemPosition = selectedItem.index() 1,LXm办公区 - 实用经验教程分享!

    leftPosition = selectedItem.offset().left,LXm办公区 - 实用经验教程分享!

    backgroundColor = selectedItem.data('color');LXm办公区 - 实用经验教程分享!

    $('.cd-marker').removeClassPrefix('color').addClass('color-' selectedItemPosition).css({LXm办公区 - 实用经验教程分享!

    'left': leftPosition,LXm办公区 - 实用经验教程分享!

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

    if( type == 'close') {LXm办公区 - 实用经验教程分享!

    $('.cd-marker').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){LXm办公区 - 实用经验教程分享!

    toggle3dBlock(false);LXm办公区 - 实用经验教程分享!

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

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

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

    $.fn.removeClassPrefix = function(prefix) {LXm办公区 - 实用经验教程分享!

    this.each(function(i, el) {LXm办公区 - 实用经验教程分享!

    var classes = el.className.split(" ").filter(function(c) {LXm办公区 - 实用经验教程分享!

    return c.lastIndexOf(prefix, 0) !== 0;LXm办公区 - 实用经验教程分享!

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

    el.className = $.trim(classes.join(" "));LXm办公区 - 实用经验教程分享!

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

    return this;LXm办公区 - 实用经验教程分享!

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

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

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

    html5 css3 jquery网页顶部3D翻转展开导航LXm办公区 - 实用经验教程分享!

  • 6

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

    html5 css3 jquery网页顶部3D翻转展开导航LXm办公区 - 实用经验教程分享!

  • 7

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

    html5 css3 jquery网页顶部3D翻转展开导航LXm办公区 - 实用经验教程分享!

  • 注意事项

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

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


    标签: HTMLJQUERY

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