Свернутое меню по-прежнему накладывает контент, как убрать поле, чтобы иметь возможность взаимодействовать с контентом? - PullRequest
0 голосов
/ 04 ноября 2018

Я создал меню с html, css и javascript. Кнопка переключения сворачивает меню навигации, добавляя класс css и добавляя width: 0px. Заголовок и меню находятся в фиксированном положении. В свернутом виде содержимое под ним видно, однако я не могу выбрать или щелкнуть что-либо в этом контенте. Я вижу, что с инструментами разработчика Chrome у него есть поле с высотой меню, по-прежнему перекрывающей этот контент. Как я могу удалить или скрыть это поле для взаимодействия с нижележащим контентом?

                <body class="home blog hfeed">
            <div id="page" class="site">
            <a class="skip-link screen-reader-text" href="#content">Skip to content</a>

            <header id="masthead" class="site-header">
            <div class="site-branding">
                <h1 class="site-title"><a href="http://localhost/somesite/" rel="home">somesite</a></h1>
                            <p class="site-description">Artist</p>
                </div><!-- .site-branding -->

            <nav id="site-navigation" class="main-navigation">
                    <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
                        <div id="nav-icon3">
                        <span></span>
                        <span></span>
                        <span></span>
                        <span></span>
                        </div>
                    </button>
                <div class="menu-short-container">
                    <ul id="primary-menu" class="menu">
                    <li id="menu-item-1629" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1629"><a href="https://wpthemetestdata.wordpress.com/">Home</a></li>
                    <li id="menu-item-1631" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-1631"><a href="http://localhost/somesite/about/">About The Tests</a>
                        <ul class="sub-menu">
                            <li id="menu-item-1632" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1632"><a href="http://localhost/somesite/about/clearing-floats/">Clearing Floats</a></li>
                            <li id="menu-item-1633" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1633"><a href="http://localhost/somesite/about/page-with-comments/">Page with comments</a></li>
                            <li id="menu-item-1634" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1634"><a href="http://localhost/somesite/about/page-with-comments-disabled/">Page with comments disabled</a></li>
                            <li id="menu-item-1708" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-1708"><a href="http://localhost/somesite/about/page-markup-and-formatting/">Page Markup And Formatting</a>
                        <ul class="sub-menu">
                            <li id="menu-item-1709" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1709"><a href="http://localhost/somesite/about/page-image-alignment/">Page Image Alignment</a></li>
                        </ul>
                        </li>
                        </ul>
                    </li>
                    <li id="menu-item-1635" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1635"><a href="http://localhost/somesite/lorem-ipsum/">Lorem Ipsum</a></li>
                    <li id="menu-item-1630" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1630"><a href="http://localhost/somesite/blog/">Blog</a></li>
                    </ul></div>     </nav><!-- #site-navigation -->
            </header><!-- #masthead -->

            <div id="content" class="site-content">

                /*--------------------------------------------------------------
            # Normalize
            --------------------------------------------------------------*/
            /* normalize.css v8.0.0 | MIT License | github.com/necolas/normalize.css */

            /* Document
                 ========================================================================== */

            /**
             * 1. Correct the line height in all browsers.
             * 2. Prevent adjustments of font size after orientation changes in iOS.
             */

            * {
                box-sizing: border-box;
              /*   border: #345345 solid 1px;
             */
              }

            html {
                line-height: 1.15; /* 1 */
                -webkit-text-size-adjust: 100%; /* 2 */
                    width: 100%; 
                    height:100%;
            }

            /* Sections
                 ========================================================================== */

            /**
             * Remove the margin in all browsers.
             */

            body {
                margin: 0;
                    padding: 0;
                    width: 100%; 
                    height:100%;
            }



            h1 {
                font-size: 2em;
                margin: 0.67em 0;
            }

            /* Grouping content
                 ========================================================================== */



            hr {
                box-sizing: content-box; /* 1 */
                height: 0; /* 1 */
                overflow: visible; /* 2 */
            }



            pre {
                font-family: monospace, monospace; /* 1 */
                font-size: 1em; /* 2 */
            }

            /* Text-level semantics
                 ========================================================================== */


            a {
                background-color: transparent;
            }



            abbr[title] {
                border-bottom: none; /* 1 */
                text-decoration: underline; /* 2 */
                text-decoration: underline dotted; /* 2 */
            }


            b,
            strong {
                font-weight: bolder;
            }



            code,
            kbd,
            samp {
                font-family: monospace, monospace; /* 1 */
                font-size: 1em; /* 2 */
            }


            small {
                font-size: 80%;
            }


            sub,
            sup {
                font-size: 75%;
                line-height: 0;
                position: relative;
                vertical-align: baseline;
            }

            sub {
                bottom: -0.25em;
            }

            sup {
                top: -0.5em;
            }

            /* Embedded content
                 ========================================================================== */

            /**
             * Remove the border on images inside links in IE 10.
             */

            img {
                border-style: none;
            }

            /* Forms
                 ========================================================================== */

            button,
            input,
            optgroup,
            select,
            textarea {
                font-family: inherit; /* 1 */
                font-size: 100%; /* 1 */
                line-height: 1.15; /* 1 */
                margin: 0; /* 2 */
            }



            button,
            input { /* 1 */
                overflow: visible;
            }


            button,
            select { /* 1 */
                text-transform: none;
            }


            button,
            [type="button"],
            [type="reset"],
            [type="submit"] {
                -webkit-appearance: button;
            }



            button::-moz-focus-inner,
            [type="button"]::-moz-focus-inner,
            [type="reset"]::-moz-focus-inner,
            [type="submit"]::-moz-focus-inner {
                border-style: none;
                padding: 0;
            }

            /**
             * Restore the focus styles unset by the previous rule.
             */

            button:-moz-focusring,
            [type="button"]:-moz-focusring,
            [type="reset"]:-moz-focusring,
            [type="submit"]:-moz-focusring {
                outline: 1px dotted ButtonText;
            }



            fieldset {
                padding: 0.35em 0.75em 0.625em;
            }



            legend {
                box-sizing: border-box; /* 1 */
                color: inherit; /* 2 */
                display: table; /* 1 */
                max-width: 100%; /* 1 */
                padding: 0; /* 3 */
                white-space: normal; /* 1 */
            }



            progress {
                vertical-align: baseline;
            }

            /**
             * Remove the default vertical scrollbar in IE 10+.
             */

            textarea {
                overflow: auto;
            }

            /**
             * 1. Add the correct box sizing in IE 10.
             * 2. Remove the padding in IE 10.
             */

            [type="checkbox"],
            [type="radio"] {
                box-sizing: border-box; /* 1 */
                padding: 0; /* 2 */
            }

            /**
             * Correct the cursor style of increment and decrement buttons in Chrome.
             */

            [type="number"]::-webkit-inner-spin-button,
            [type="number"]::-webkit-outer-spin-button {
                height: auto;
            }

            /**
             * 1. Correct the odd appearance in Chrome and Safari.
             * 2. Correct the outline style in Safari.
             */

            [type="search"] {
                -webkit-appearance: textfield; /* 1 */
                outline-offset: -2px; /* 2 */
            }

            /**
             * Remove the inner padding in Chrome and Safari on macOS.
             */

            [type="search"]::-webkit-search-decoration {
                -webkit-appearance: none;
            }

            /**
             * 1. Correct the inability to style clickable types in iOS and Safari.
             * 2. Change font properties to `inherit` in Safari.
             */

            ::-webkit-file-upload-button {
                -webkit-appearance: button; /* 1 */
                font: inherit; /* 2 */
            }

            /* Interactive
                 ========================================================================== */

            /*
             * Add the correct display in Edge, IE 10+, and Firefox.
             */

            details {
                display: block;
            }

            /*
             * Add the correct display in all browsers.
             */

            summary {
                display: list-item;
            }

            /* Misc
                 ========================================================================== */

            /**
             * Add the correct display in IE 10+.
             */

            template {
                display: none;
            }

            /**
             * Add the correct display in IE 10.
             */

            [hidden] {
                display: none;
            }

            /*--------------------------------------------------------------
            # Typography
            --------------------------------------------------------------*/
            body,
            button,
            input,
            select,
            optgroup,
            textarea {
                color: #404040;
                font-family: sans-serif;
                font-size: 16px;
                font-size: 1rem;
                line-height: 1.5;
            }

            h1, h2, h3, h4, h5, h6 {
                clear: both;
                    font-family: 'Cormorant Garamond', serif;
                    font-size: 2.5rem;
            }




            p {
                margin-bottom: 1.5em;
                     font-family: "Roboto", 'Open Sans', sans-serif;
                     }

            dfn, cite, em, i {
                font-style: italic;
            }

            blockquote {
                margin: 0 1.5em;
            }

            address {
                margin: 0 0 1.5em;
            }

            pre {
                background: #eee;
                font-family: "Courier 10 Pitch", Courier, monospace;
                font-size: 15px;
                font-size: 0.9375rem;
                line-height: 1.6;
                margin-bottom: 1.6em;
                max-width: 100%;
                overflow: auto;
                padding: 1.6em;
            }

            code, kbd, tt, var {
                font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
                font-size: 15px;
                font-size: 0.9375rem;
            }

            abbr, acronym {
                border-bottom: 1px dotted #666;
                cursor: help;
            }

            mark, ins {
                background: #fff9c0;
                text-decoration: none;
            }

            big {
                font-size: 125%;
            }

            /*--------------------------------------------------------------
            # Elements
            --------------------------------------------------------------*/
            html {
                box-sizing: border-box;
            }

            *,
            *:before,
            *:after {
                /* Inherit box-sizing to make it easier to change the property for components that leverage other behavior; see https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/ */
                box-sizing: border-box;
            }

            body {
                background: #fff;
                /* Fallback for when there is no custom background color defined. */
            }

            hr {
                background-color: #ccc;
                border: 0;
                height: 1px;
                margin-bottom: 1.5em;
            }

            ul, ol {
                margin: 0 0 1.5em 3em;
            }

            ul {
                list-style: disc;
            }

            ol {
                list-style: decimal;
            }

            li > ul,
            li > ol {
                margin-bottom: 0;
                margin-left: 1.5em;
            }

            dt {
                font-weight: bold;
            }

            dd {
                margin: 0 1.5em 1.5em;
            }

            img {
                height: auto;
                /* Make sure images are scaled correctly. */
                max-width: 100%;
                /* Adhere to container width. */
            }

            figure {
                margin: 1em 0;
                /* Extra wide images within figure tags don't overflow the content area. */
            }

            table {
                margin: 0 0 1.5em;
                width: 100%;
            }

            /*--------------------------------------------------------------
            # Forms
            --------------------------------------------------------------*/
            button,
            input[type="button"],
            input[type="reset"],
            input[type="submit"] {
                background: #ededed;
                color: #000000;
                font-size: 12px;
                font-size: 0.75rem;
                line-height: 1;
                padding: 1em;
                    border: none;

            }

            button:hover,
            input[type="button"]:hover,
            input[type="reset"]:hover,
            input[type="submit"]:hover {
                border-color: #ccc #bbb #aaa;
            }

            button:active, button:focus,
            input[type="button"]:active,
            input[type="button"]:focus,
            input[type="reset"]:active,
            input[type="reset"]:focus,
            input[type="submit"]:active,
            input[type="submit"]:focus {
                border-color: #aaa #bbb #bbb;
            }

            input[type="text"],
            input[type="email"],
            input[type="url"],
            input[type="password"],
            input[type="search"],
            input[type="number"],
            input[type="tel"],
            input[type="range"],
            input[type="date"],
            input[type="month"],
            input[type="week"],
            input[type="time"],
            input[type="datetime"],
            input[type="datetime-local"],
            input[type="color"],
            textarea {
                color: #666;
                border: 1px solid #ccc;
                border-radius: 3px;
                padding: 3px;
            }

            input[type="text"]:focus,
            input[type="email"]:focus,
            input[type="url"]:focus,
            input[type="password"]:focus,
            input[type="search"]:focus,
            input[type="number"]:focus,
            input[type="tel"]:focus,
            input[type="range"]:focus,
            input[type="date"]:focus,
            input[type="month"]:focus,
            input[type="week"]:focus,
            input[type="time"]:focus,
            input[type="datetime"]:focus,
            input[type="datetime-local"]:focus,
            input[type="color"]:focus,
            textarea:focus {
                color: #111;
            }

            select {
                border: 1px solid #ccc;
            }

            textarea {
                width: 100%;
            }

            /*--------------------------------------------------------------
            # Navigation
            --------------------------------------------------------------*/
            /*--------------------------------------------------------------
            ## Links
            --------------------------------------------------------------*/

            a {
                    text-decoration: none;
                    font-family: 'Cormorant Garamond', serif;
                    font-size: 1.2rem;
                    color: #000000;

            }


            a:visited {
                color: #000000;
            }

            a:hover, a:focus, a:active {
                color: #AA8130;
            }

            a:focus {
                outline: thin dotted;
            }

            a:hover, a:active {
                outline: 0;
            }

            /*--------------------------------------------------------------
            ## Menus
            --------------------------------------------------------------*/
            .main-navigation {
                display: block;
                    position: fixed;
                    top:0;
                    width: 100%;

                    }

            .main-navigation div {
                    position: fixed;
                    z-index: 99;
                    top: 100px;
                    margin:0;
                    padding:0;
                    width: 100%;
                    height: auto;
                    overflow:hidden;
                    }


            .main-navigation ul {
                /*display: none; */
                list-style: none;
                margin: 0;
                    padding-left: 0;
                    /*height: 100vh; */
                        background-color: #ffffff;



                width: 0; /* 0 width - change this with JavaScript */
                /*position: fixed;  Stay in place */
                /*z-index: 1; /* Stay on top */
                /*top: 0; /* Stay at the top */
                /*left: 0;*/
                background-color: #ededed; /* Black*/
                overflow-x: hidden; /* Disable horizontal scroll */
                /*padding-top: 60px; /* Place content 60px from the top */


                transition: 2s;
                 -webkit-transition: width 2s; /* Safari */
                 transition-timing-function: ease-in;
                 transition-timing-function: cubic-bezier(0.2,0.1,0.1,1);

            }

            .main-navigation ul ul {
                    display: none;
                    padding-top: 0;
                z-index: 99999;
                    border: #ededed solid 1px;
                    background: rgba(250, 250, 250, 0.1); 
                    transition: 2s;
                      -webkit-transition: height 2s; /* Safari */
                      transition-timing-function: ease-in; 
                      transition-timing-function: cubic-bezier(0.2,0.1,0.1,1);

            }

            .main-navigation ul ul ul {
                top: 0;
            }

            .main-navigation ul ul li {
                padding-left: 0.5em;

            }

            .main-navigation ul ul li:hover > ul,
            .main-navigation ul ul li.focus > ul {
                left: 100%;
            }

            .main-navigation ul ul a {
                width: 200px;
            }

            .main-navigation ul li:hover > ul,
            .main-navigation ul li.focus > ul {
                left: auto;
            }

            .main-navigation li {
                position: relative;
                    padding-left:20px;

            }

            .main-navigation a {
                display: inline-block;
                width: 100%;
                padding: .5em 1em .5em 0;
                text-decoration: none;
                color: #000000;
                  white-space: nowrap;
            }

            .main-navigation a:hover,
            .main-navigation a:focus {
                text-decoration: underline;
            }

            .main-navigation .menu-item-has-children,
            .main-navigation .page_item_has_children {
                min-width: 218px;
            }

            .main-navigation .menu-item-has-children > a,
            .main-navigation .page_item_has_children > a {
                padding-right: 2em;
            }

            button.dropdown-toggle {
                position: absolute;
                right: 0;
                border: none;
                background: inherit;
                color: #000000;
                line-height: 1.5em;
                    font-size: 1.2rem;
                    padding: .5em 1em .5em 0;
                    width: 100%;
                    height: 100%;
                    text-align: right;
                }

                    button.dropdown-toggle span{
                        position: absolute;
                        top: 0;
                        padding: .5em 1em .5em 0;
                        padding-right:0;

                    }

            .menu-toggle {
                position: absolute;
                top: 0;
                left: 0;
                display: block;
                font-size: 80%;
                text-transform: uppercase;
                color: #000000;
                    margin-top: 20px;
                    margin-left: 20px;  
                    padding:0;
                    background:none;

            }

            /* Toggle small menu and children on */
            .toggled-on ul,
            .sub-menu.toggled-on {
                display: block;
                    width: 100%;


                    transition: 2s; /* 0.2 second transition effect to slide in the sidenav */ 
                    -webkit-transition: width 2s; /* Safari */
                    transition-timing-function: ease-in;
                    transition-timing-function: cubic-bezier(0.2,0.1,0.1,1);
            }
            .sub-menu.toggled-on {
                height: auto;
                transition: 2s; /* 0.2 second transition effect to slide in the sidenav */ 
                    -webkit-transition: height 2s; /* Safari */
             transition-timing-function: ease-in;
                    transition-timing-function: cubic-bezier(0.2,0.1,0.1,1);}


            @media screen and (min-width: 600px) {
                .menu-toggle {
                    display: none;
                }
                .main-navigation .menu-item-has-children > a,
                .main-navigation .page_item_has_children > a {
                    padding-right: 2em;
                    background: rgba(255, 255, 255, 0.1);
                }
                .main-navigation ul {
                        position: relative;
                            width: 100%;
                            height: auto;
                            overflow-y: visible;
                            overflow-x: visible;
                    display: block;
                    display: -webkit-box;
                    display: -ms-flexbox;
                    display: flex;
                    -ms-flex-wrap: wrap;
                        flex-wrap: wrap;
                }
                .main-navigation ul ul {
                    -webkit-box-orient: vertical;
                    -webkit-box-direction: normal;
                        -ms-flex-direction: column;
                            flex-direction: column;

                    margin-left: 0;

                }
                .main-navigation ul ul li {
                    padding-left: 0;
                }
                .main-navigation ul ul li a {
                    width: 218px;
                    background: none;
                }
                .main-navigation ul li a {
                    padding: .4em 1em;

                }
            }

            @media screen and (min-width: 900px) {
                .main-navigation ul {
                    -webkit-box-pack: end;
                        -ms-flex-pack: end;
                            justify-content: flex-end;
                    padding-top: 0;
                    /* If you want dropdowns to open on hover, uncomment this: */
                    /*
                        li:hover > ul,
                            li:focus > ul {
                            display: block;
                        }
                        */
                }
            }




            /* Icon 1 */

            #nav-icon3 {
              width: 30px;
              height: 24px;
              position: relative;
              top:0;
              margin: 0 auto;
              -webkit-transform: rotate(0deg);
              -moz-transform: rotate(0deg);
              -o-transform: rotate(0deg);
              transform: rotate(0deg);
              -webkit-transition: .5s ease-in-out;
              -moz-transition: .5s ease-in-out;
              -o-transition: .5s ease-in-out;
              transition: .5s ease-in-out;
              cursor: pointer;
            }

             #nav-icon3 span {
              display: block;
              position: absolute;
              height: 3px;
              width: 100%;
              background: #000000;
              border-radius: 3px;
              opacity: 1;
              left: 0;
              -webkit-transform: rotate(0deg);
              -moz-transform: rotate(0deg);
              -o-transform: rotate(0deg);
              transform: rotate(0deg);
              -webkit-transition: .25s ease-in-out;
              -moz-transition: .25s ease-in-out;
              -o-transition: .25s ease-in-out;
              transition: .25s ease-in-out;
            }

            /* Icon 3 */

            #nav-icon3 span:nth-child(1) {
              top: 0px;
            }

            #nav-icon3 span:nth-child(2),#nav-icon3 span:nth-child(3) {
              top: 9px;
            }

            #nav-icon3 span:nth-child(4) {
              top: 18px;
            }

            #nav-icon3.open span:nth-child(1) {
              top: 9px;
              width: 0%;
              left: 50%;
            }

            #nav-icon3.open span:nth-child(2) {
              -webkit-transform: rotate(45deg);
              -moz-transform: rotate(45deg);
              -o-transform: rotate(45deg);
              transform: rotate(45deg);
            }

            #nav-icon3.open span:nth-child(3) {
              -webkit-transform: rotate(-45deg);
              -moz-transform: rotate(-45deg);
              -o-transform: rotate(-45deg);
              transform: rotate(-45deg);
            }

            #nav-icon3.open span:nth-child(4) {
              top: 9px;
              width: 0%;
              left: 50%;
            }

            /* 


            /*--------------------------------------------------------------
            # Accessibility
            --------------------------------------------------------------*/
            /* Text meant only for screen readers. */
            .screen-reader-text {
                border: 0;
                clip: rect(1px, 1px, 1px, 1px);
                clip-path: inset(50%);
                height: 1px;
                margin: -1px;
                overflow: hidden;
                padding: 0;
                position: absolute !important;
                width: 1px;
                word-wrap: normal !important; /* Many screen reader and browser combinations announce broken words as they would appear visually. */
            }

            .screen-reader-text:focus {
                background-color: #f1f1f1;
                border-radius: 3px;
                box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
                clip: auto !important;
                clip-path: none;
                color: #21759b;
                display: block;
                font-size: 14px;
                font-size: 0.875rem;
                font-weight: bold;
                height: auto;
                left: 5px;
                line-height: normal;
                padding: 15px 23px 14px;
                text-decoration: none;
                top: 5px;
                width: auto;
                z-index: 100000;
                /* Above WP toolbar. */
            }

            /* Do not show the outline on the skip link target. */
            #content[tabindex="-1"]:focus {
                outline: 0;
            }

            /*--------------------------------------------------------------
            # Alignments
            --------------------------------------------------------------*/
            .alignleft {
                display: inline;
                float: left;
                margin-right: 1.5em;
            }

            .alignright {
                display: inline;
                float: right;
                margin-left: 1.5em;
            }

            .aligncenter {
                clear: both;
                display: block;
                margin-left: auto;
                margin-right: auto;
            }

            /*--------------------------------------------------------------
            # Clearings
            --------------------------------------------------------------*/
            .clear:before,
            .clear:after,
            .entry-content:before,
            .entry-content:after,
            .comment-content:before,
            .comment-content:after,
            .site-header:before,
            .site-header:after,
            .site-content:before,
            .site-content:after,
            .site-footer:before,
            .site-footer:after {
                content: "";
                display: table;
                table-layout: fixed;
            }

            .clear:after,
            .entry-content:after,
            .comment-content:after,
            .site-header:after,
            .site-content:after,
            .site-footer:after {
                clear: both;
            }

            /*--------------------------------------------------------------
            # Widgets
            --------------------------------------------------------------*/
            .widget {
                margin: 0 0 1.5em;
                /* Make sure select elements fit in widgets. */
            }

            .widget select {
                max-width: 100%;
            }

            /*--------------------------------------------------------------
            # Content
            --------------------------------------------------------------*/

            .site-header {
                position: fixed;
                top:0;
                background:#ffffff;
                width: 100%;
                height: auto;
                min-height: 80px;
            }

            .site-branding {
                position: absolute;
                top:0;
                left: 0;
                right: 0;
                margin: auto;
                text-align: center;
                width: 20%;
                min-width: 300px;
            }

            .site-branding  .site-title{
                    margin:0;
                    line-height: 30px;
                    padding-top:15px;
                    font-size: 30px;
                }


            .site-branding  .site-title a{
                    font-size: 30px;

                }


             .site-branding p{
                    margin:0;
                    line-height: 30px;
                }


            .site-content {
                margin-top: 100px;
                padding: 20px;
            }
...