RESPONSIVE MENU HORIZONTAL (second level with input)

HTML
<!DOCTYPE html> <html lang="zxx"> <!--[if lte IE 8]> <html lang="en" class="oldbro"> <![endif]--> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes"> <title>Portfolio</title> <link rel="stylesheet" href="css.css"> <link href="https://fonts.googleapis.com/css?family=K2D:400,400i&subset=latin-ext" rel="stylesheet"> <noscript> <link rel="stylesheet" href="nos.css"> </noscript> <script> document.createElement("article"); document.createElement("footer"); document.createElement("header"); document.createElement("hgroup"); document.createElement("nav"); </script> </head> <body id="body"> <div class="wrp"> <div class="navwrap"> <header>header</header> <div class="nav" role="navigation"> <input type="checkbox" class="menu" id="menu"> <label for="menu"><span class="burg"><i></i><i></i><i></i><i></i></span></label> <a class="navi" href="index.html">Portfolio</a> <a class="navi" href="about.html">About</a> <div class="navi"> <input type="checkbox" id="a"> <label for="a"><a href="#">Programing</a></label> <ul> <li><a href="#c">c++</a></li> <li><a href="javascript.html">JavaScript</a></li> <li><a href="#p">PHP</a></li> <li><a href="#h">HTML5</a></li> <li><a href="css.html">CSS</a></li> </ul> </div> <div class="navi"> <input type="checkbox" id="b"> <label for="b"><a href="#">Graphics</a></label> <ul> <li><a href="https://openclipart.org/user-detail/Keistutis" target="_blank">Inkscape</a></li> <li><a href="#">Blender</a></li> <li><a href="#">Gimp</a></li> <li><a href="#">Sweet Home3D</a></li> </ul> </div> </div> </div> <div id="content"> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Urna nec tincidunt praesent semper feugiat. Eget felis eget nunc lobortis mattis. Purus faucibus ornare suspendisse sed nisi lacus sed viverra tellus. Diam quam nulla porttitor massa id neque aliquam. Scelerisque eleifend donec pretium vulputate sapien nec sagittis aliquam. Bibendum ut tristique et egestas quis ipsum suspendisse. Scelerisque varius morbi enim nunc faucibus a pellentesque. Risus pretium quam vulputate dignissim suspendisse in est ante in. Fusce id velit ut tortor pretium. In hendrerit gravida rutrum quisque non. Tortor vitae purus faucibus ornare suspendisse sed nisi lacus. Pulvinar sapien et ligula ullamcorper malesuada. Gravida cum sociis natoque penatibus. Bibendum ut tristique et egestas quis ipsum suspendisse. Duis at consectetur lorem donec massa. Tellus in hac habitasse platea.</p><p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Urna nec tincidunt praesent semper feugiat. Eget felis eget nunc lobortis mattis. Purus faucibus ornare suspendisse sed nisi lacus sed viverra tellus. Diam quam nulla porttitor massa id neque aliquam. Scelerisque eleifend donec pretium vulputate sapien nec sagittis aliquam. Bibendum ut tristique et egestas quis ipsum suspendisse. Scelerisque varius morbi enim nunc faucibus a pellentesque. Risus pretium quam vulputate dignissim suspendisse in est ante in. Fusce id velit ut tortor pretium. In hendrerit gravida rutrum quisque non. Tortor vitae purus faucibus ornare suspendisse sed nisi lacus. Pulvinar sapien et ligula ullamcorper malesuada. Gravida cum sociis natoque penatibus. Bibendum ut tristique et egestas quis ipsum suspendisse. Duis at consectetur lorem donec massa. Tellus in hac habitasse platea.</p><p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Urna nec tincidunt praesent semper feugiat. Eget felis eget nunc lobortis mattis. Purus faucibus ornare suspendisse sed nisi lacus sed viverra tellus. Diam quam nulla porttitor massa id neque aliquam. Scelerisque eleifend donec pretium vulputate sapien nec sagittis aliquam. Bibendum ut tristique et egestas quis ipsum suspendisse. Scelerisque varius morbi enim nunc faucibus a pellentesque. Risus pretium quam vulputate dignissim suspendisse in est ante in. Fusce id velit ut tortor pretium. In hendrerit gravida rutrum quisque non. Tortor vitae purus faucibus ornare suspendisse sed nisi lacus. Pulvinar sapien et ligula ullamcorper malesuada. Gravida cum sociis natoque penatibus. Bibendum ut tristique et egestas quis ipsum suspendisse. Duis at consectetur lorem donec massa. Tellus in hac habitasse platea.</p><p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Urna nec tincidunt praesent semper feugiat. Eget felis eget nunc lobortis mattis. Purus faucibus ornare suspendisse sed nisi lacus sed viverra tellus. Diam quam nulla porttitor massa id neque aliquam. Scelerisque eleifend donec pretium vulputate sapien nec sagittis aliquam. Bibendum ut tristique et egestas quis ipsum suspendisse. Scelerisque varius morbi enim nunc faucibus a pellentesque. Risus pretium quam vulputate dignissim suspendisse in est ante in. Fusce id velit ut tortor pretium. In hendrerit gravida rutrum quisque non. Tortor vitae purus faucibus ornare suspendisse sed nisi lacus. Pulvinar sapien et ligula ullamcorper malesuada. Gravida cum sociis natoque penatibus. Bibendum ut tristique et egestas quis ipsum suspendisse. Duis at consectetur lorem donec massa. Tellus in hac habitasse platea.</p> </div> <div id="footer"> <div class="wrap"> </div> </div> </div> <script src="js/script.js"></script> </body> </html>
CSS
@charset "UTF-8"; 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; outline: 0; } article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } body { line-height: 1; } ol, ul { list-style: none; display: block; } blockquote, q { quotes: none; } blockquote:before, blockquote:after { content: ''; content: none; } q:before, q:after { content: ''; content: none; } table { border-collapse: collapse; border-spacing: 0; } * { box-sizing: border-box; } button { outline: none; outline-color: #eee; } button:focus, button:active, button:hover { outline: none; outline-color: #eee; } input[type="button"] { outline: none; } input[type="button"]::-moz-focus-inner { border: 0; } button::-moz-focus-inner { border: 0; } #kspiner { border-radius: 24px; height: 48px; width: 48px; display: block; content: ''; position: absolute; left: 0; right: 0; top: 0; bottom: 0; border: 4px solid rgba(0, 234, 242, 0.4); border-top: 4px solid rgba(0, 0, 0, 0.4); border-bottom: 4px solid rgba(0, 0, 0, 0.4); margin: auto; z-index: 1; animation: 0.7s loader linear infinite; } @keyframes loader { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } html, body { overflow: hidden; } body { font: 1em/1.5 Helvetica,sans-serif; color: #555; background: #214478; overscroll-behavior: none; } a { color: #555; } a:focus { outline: 0; } a:link, a:visited, a:focus, a:active { text-decoration: none; } a:hover { text-decoration: none; cursor: pointer; } pre { overflow: auto; } pre > code { display: block; word-wrap: normal; font-family: monospace, monospace; } pre > code > span { background: #eee; } #progress { width: 0; height: 2px; background: #fff; position: fixed; top: 0; left: 0; transform: translateZ(0); z-index: 9998; background: #fc0; } h1 { text-align: center; } .imglogo { display: block; height: 240px; border: 1px solid #999; } .imglogo:hover { filter: grayscale(80%); } img { display: block; width: 100%; height: 100%; object-fit: cover; -ms-interpolation-mode: nearest-neighbor; image-rendering: -webkit-optimize-contrast; image-rendering: -moz-crisp-edges; image-rendering: -o-pixelated; image-rendering: pixelated; } .wrp { background: radial-gradient(circle, rgba(0, 0, 0, 0) 50%, #821f69 100%) fixed, repeating-linear-gradient(135deg, #c8a5b4 0px, #cdaab9 0px, #d2afbe 24px, #d7b4c3 24px, #dcb9c8 48px, #e1becd 48px, #e6c3d2 72px, #ebc8d7 72px, #f0cddc 96px, #f5d2e1 96px, #fad7e6 120px, #f5d2e1 120px, #f0cddc 144px, #ebc8d7 144px, #e6c3d2 168px, #e1becd 168px, #dcb9c8 192px, #d7b4c3 192px, #d2afbe 216px, #cdaab9 216px) fixed; display: block; bottom: 0; top: 0; overflow-y: scroll; position: absolute; height: 100%; width: 100%; } header { z-index: 9998; height: 0; transition: .2s ease-out; border-top: 1px solid #fff; } #content { position: relative; padding: 0 12px 24px; background: repeating-linear-gradient(135deg, #afa5aa 0px, #b4aaaf 0px, #b9afb4 24px, #beb4b9 24px, #c3b9be 48px, #c8bec3 48px, #cdc3c8 72px, #d2c8cd 72px, #d7cdd2 96px, #dcd2d7 96px, #e1d7dc 120px, #dcd2d7 120px, #d7cdd2 144px, #d2c8cd 144px, #cdc3c8 168px, #c8bec3 168px, #c3b9be 192px, #beb4b9 192px, #b9afb4 216px, #b4aaaf 216px) fixed; text-align: justify; margin: 48px auto; } #footer { position: relative; text-align: right; width: 100%; min-height: 72px; } #footcont { text-align: right; } .white { color: white; background: #008080; padding: 24px; border-radius: 24px; -webkit-border-radius: 24px; -moz-border-radius: 24px; } .pad { padding: 0 12px; } .w50 { padding: 0 0 12px 0; position: relative; display: block; } .clearfix:before { content: ""; display: block; height: 0; width: 0; } .clearfix:after { content: ""; display: block; height: 0; width: 0; clear: both; } #footer:after { background: repeating-linear-gradient(90deg, #c8a5b4 0px, #cdaab9 0px, #d2afbe 34px, #d7b4c3 34px, #dcb9c8 68px, #e1becd 68px, #e6c3d2 102px, #ebc8d7 102px, #f0cddc 136px, #f5d2e1 136px, #fad7e6 170px, #f5d2e1 170px, #f0cddc 204px, #ebc8d7 204px, #e6c3d2 238px, #e1becd 238px, #dcb9c8 272px, #d7b4c3 272px, #d2afbe 306px, #cdaab9 306px); display: block; width: 100%; top: 100%; left: 0; text-align: center; content: "Oops some glitch happened!"; line-height: 100px; height: 100px; z-index: -1; } .navwrap { z-index: 998; display: block; width: 100%; position: fixed; top: 0; white-space: nowrap; text-align: right; max-height: 100%; overflow-y: auto; overscroll-behavior-y: contain; } .nav { line-height: 3; transition: .2s ease-out; box-shadow: 0 -1px 0 0 #ddd inset, 0 1px 2px 0 #777; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -moz-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; standard-user-select: none; backface-visibility: hidden; transform: translateZ(0); -ms-transform: translateZ(0); width: 100%; display: block; background: #000; font-family: 'K2D', sans-serif; } .nav:not(a) { font-size: 0; } .nav .navi { font-size: initial; background: #eee; text-transform: uppercase; text-align: left; cursor: pointer; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); box-shadow: -1px 0 0 0 #fff, 1px -1px 0 0 #ddd inset; } .nav .navi input + label:before { display: block; float: left; content: "↱"; text-align: center; width: 1em; } .nav label { width: 100%; width: -webkit-min-content; width: -moz-min-content; width: min-content; cursor: pointer; } .nav > label { font-size: 1.5em; line-height: 2; color: #eee; display: block; } .nav a { display: block; text-decoration: none; padding: 0 1.5em; color: #555; box-shadow: 1px 0 0 0 #fff, 2px 0 0 0 #ddd; } .nav a:focus { outline: 0; background: #fafafa; } .nav input + label > a:first-child { pointer-events: none; } .nav .navi { display: none; } .nav .navi:focus-within ul { display: initial; } .nav .navi:focus-within label:before { transform: rotate(90deg); transition: 0.2s; } .nav .navi ul { display: none; text-transform: capitalize; overflow: hidden; } .nav .navi ul a { box-shadow: 0 1px 0 0 #fff inset, 0 -1px 0 0 #ddd inset; } .nav .navi li a:hover, .nav .navi li a:focus { background: #fff; color: #333; } .nav .navi input:checked ~ ul { display: block; background: #fafafa; } .nav .navi input:checked + label:before { transform: rotate(90deg); transition: 0.2s; } .nav .navi:hover { background: #fafafa; transition: 0.2s; } .nav input[type="checkbox"] { display: none; } .nav .menu:checked ~ .navi { display: block; } .burg { overflow: hidden; border-radius: 2px; display: block; cursor: pointer; height: 48px; width: 100%; z-index: 9998; padding: 14px 12px 10px; direction: rtl; } .burg i { display: block; height: 2px; width: 24px; font-size: 0; margin: 0 0 4px 0; background: #fafafa; text-align: center; } .burg i:nth-child(1) { animation: leb 0.2s backwards; animation-direction: reverse; } .burg i:nth-child(2) { animation: outT 0.2s backwards; animation-direction: reverse; } .burg i:nth-child(3) { animation: outB 0.2s backwards; animation-direction: reverse; } .burg i:nth-child(4) { animation: rab 0.2s backwards; animation-direction: reverse; } .menu:checked ~ label i:nth-child(1) { animation: le 0.2s forwards; } .menu:checked ~ label i:nth-child(2) { animation: inT 0.1s forwards; } .menu:checked ~ label i:nth-child(3) { animation: inB 0.1s forwards; } .menu:checked ~ label i:nth-child(4) { animation: ra 0.2s forwards; } @keyframes inT { 0% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(4px) rotate(0deg); } 100% { transform: translateY(4px) rotate(135deg); } } @keyframes inB { 0% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-2px) rotate(0deg); } 100% { transform: translateY(-2px) rotate(45deg); } } @keyframes outT { 0% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(4px) rotate(0deg); } 100% { transform: translateY(4px) rotate(135deg); } } @keyframes outB { 0% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-2px) rotate(0deg); } 100% { transform: translateY(-2px) rotate(45deg); } } @keyframes le { 0% { transform: translateX(0); } 50% { transform: translateX(6px); } 100% { transform: translateX(48px); } } @keyframes ra { 0% { transform: translateX(0); } 50% { transform: translateX(-6px); } 100% { transform: translateX(-48px); } } @keyframes leb { 0% { transform: translateX(0); } 50% { transform: translateX(6px); } 100% { transform: translateX(-48px); } } @keyframes rab { 0% { transform: translateX(0); } 50% { transform: translateX(-6px); } 100% { transform: translateX(-60px); } } @media only screen and (min-width: 481px) { .navwrap { overflow-y: visible; } .nav { padding: 0 240px 0 0; display: block; background: #eee; white-space: nowrap; } .nav .navi { display: inline-block; direction: rtl; } .nav .navi ul { display: block; position: absolute; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; box-shadow: 0 2px 1px 1px #777; background: #fafafa; min-width: 192px; margin: 0 0 0 1px; left: -9999px; overflow: auto; overscroll-behavior-y: contain; } .nav .navi label { pointer-events: none; } .nav .navi:hover ul { z-index: 1; left: auto; display: block; } .nav .navi a { direction: ltr; text-align: right; } .nav > :hover label:before { transform: rotate(90deg); transition: 0.2s; } .nav > label { display: none; } .nav .menu:checked ~ .navi { display: inline-block; } header { height: 72px; background: #fff; } #footer .wrap { padding: 24px; font-size: 10px; } #content, #footer .wrap { width: 1000px; margin: 0 auto; } #content { margin-top: 120px; border-top: 1px solid #eee; box-shadow: 0px 1px 1px 0px #333; } .w50 { overflow: hidden; width: 50%; float: left; padding: 24px 12px 0; min-height: 120px; position: relative; } } button { background: #eee; margin: 12px 0; color: #555; padding: 0 .75em; line-height: 1.5; font-size: 16px; box-sizing: border-box; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; border: 0; text-shadow: 0 1px 0 #fff; -webkit-box-shadow: inset 0 1px 0 #eee, 0 1px 1px #333; -moz-box-shadow: inset 0 1px 0 #eee, 0 1px 1px #333; box-shadow: inset 0 1px 0 #eee, 0 1px 1px #333; -webkit-transition-duration: 0.2s; -moz-transition-duration: 0.2s; transition-duration: 0.2s; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; vertical-align: top; } button:hover { background: #eee; text-decoration: none; cursor: pointer; color: #555; background: linear-gradient(#e2e2e2 0%, #dbdbdb 50%, #d1d1d1 51%, #fefefe 100%); } button:active { -webkit-box-shadow: inset 0 1px 2px #555; -moz-box-shadow: inset 0 1px 2px #555; box-shadow: inset 0 1px 2px #555; background: #ccc; } .big { padding: .75em; } /*############################################text styling############################################*/ h5, .class10 { font-size: .625em; line-height: 2.4em; margin-top: 2.4em; } h4, .class12 { font-size: .75em; line-height: 2em; margin-top: 2em; } h3, .class16 { font-size: 1em; line-height: 1.5em; margin-top: 1.5em; } h2, .class20 { font-size: 1.25em; line-height: 1.2em; margin-top: 1.2em; } h1, .class24 { font-size: 1.5em; line-height: 1em; margin-top: 1em; } /*############################################text styling############################################*/
JAVASCRIPT
(function() { "use strict"; let i = document.getElementsByClassName("wrp")[0], j = document.createElement("div"), k = document.getElementsByClassName("nav")[0], l = k.getElementsByClassName("navi"), m = document.getElementsByTagName("header")[0], n = document.getElementById("content"), o = k.getElementsByTagName("ul"), p = document.getElementsByClassName("navwrap")[0]; function a() { let t = i.offsetHeight - p.offsetHeight; [...o].forEach(u => { t < u.offsetHeight ? (u.style.height = t + "px") : u.removeAttribute("style"); }); } function b(t) { return t.offsetWidth - t.clientWidth; } function c() { k.style.paddingRight = 480 < k.offsetWidth ? n.offsetLeft + b(i) + 1 + "px" || null : null; } function f() { document.getElementById("kspiner").style.display = "none"; } function g() { let u = i.scrollHeight - innerHeight; (j.style.width = 100 * (i.scrollTop / u) + "%"), (m.style.height = 120 < i.scrollTop && 480 < k.offsetWidth ? 0 : null); } window.addEventListener("resize", function() { c(), 480 < k.offsetWidth && a(); }); var q = document.createElement("div"); (q.id = "kspiner"), i.appendChild(q), (j.id = "progress"), i.appendChild(j); var r = 0, s = !1; i.addEventListener("scroll", function() { (r = this.scrollTop), s || (window.requestAnimationFrame(function() { g(r), (s = !1); }), (s = !0)); }), (function() { setTimeout(f, 1e3); })(), c(), a(); })();
Expand for more options Login