如何将侧边菜单置于页面内容上方?

时间:2019-06-03 07:24:12

标签: css responsive-design sidebar navigationbar side-menu

我正在尝试此网站的移动优先方法,但是,当单击按钮后弹出侧面菜单时,只有一部分菜单位于页面内容下方,而其余部分则应位于顶部。

尝试解决此类问题时还有哪些其他选择?

我尝试将侧边菜单从该部分移到下面,但没有用

我尝试在.side-nav类上使用z-index-无效

function toggleNav() {
  document.getElementById("side-menu").style.width = "50%";
  document.getElementById("side-menu").style.display = "block";
  document.getElementById("side-hidden").style.width = "50%";
  document.getElementById("noScroll").style.overflow = "hidden";
}

function closeSideMenu() {
  document.getElementById("side-menu").style.width = "0";
  document.getElementById("side-hidden").style.width = "0";
  document.getElementById("noScroll").style.overflow = "scroll";
}
.container {
  padding: 0 1em;
}

body {
  margin: 0;
  font-family: 'Raleway', sans-serif;
  text-align: center;
}


/*-- ---------------------------------------------------------------- -->
<!--                        NAVIGATION                                -->
<!-- --------------------------------------------------------------- --*/

.navbar {
  background-color: #FFFFFF;
  width: 100%;
  height: 78px;
  border-bottom: 8px solid #CE2026;
}

.navbar-links {
  display: none;
}

#logo {
  display: none;
}

.open-slide {
  float: right;
  margin-top: 25px;
  margin-right: 20px;
  display: block;
}
<!DOCTYPE html>
<html>

<head>
  <link rel="stylesheet" href="style.css">
  <link href="https://fonts.googleapis.com/css?family=Raleway:300,500,700,900" rel="stylesheet">
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.css">
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>Brushworks NW Inc.</title>
</head>

<body id="noScroll">
  <!-- ----------------------------------------------------------------------------------- -->
  <!--                                  NAVIGATION                                         -->
  <!-- ----------------------------------------------------------------------------------- -->
  <nav class="navbar grid animated fadeIn">
    <div class="open-slide">
      <div>
        <a href="#" onclick="toggleNav()">
          <svg width="30" height="30">
	                    <path d="M0,5 35,5" stroke="#000" stroke-width="2"/>
	                    <path d="M0,14 35,14" stroke="#000" stroke-width="2"/>
	                    <path d="M0,23 35,23" stroke="#000" stroke-width="2"/>
	                </svg>
        </a>
      </div>
    </div>
    <ul class="navbar-links">
      <li><a class="active" href="#">HOME</a></li>
      <li><a href="#">ABOUT US</a></li>
      <li><a href="#">SERVICES</a></li>
      <li><a href="#">GALLERY</a></li>
      <li><a href="#">CONTACT US</a></li>
      <li id="number">(360) 679-4444</li>
    </ul>
    <div id="side-hidden-parent">
      <div id="side-hidden"></div>
    </div>
    <div id="side-menu" class="side-nav">
      <ul class="on-top">
        <li><a href="#" class="btn-close" onclick="closeSideMenu()">&times;</a></li>
        <li class="nav-item"><a class="side-active" href="#">Home</a></li>
        <li class="nav-item"><a href="#">About</a></li>
        <li class="nav-item"><a href="#">Services</a></li>
        <li class="nav-item"><a href="#">Contact</a></li>
      </ul>
    </div>
  </nav>
  <header id="hero" class="grid">
    <div class="container">
      <img id="logo" class="animated fadeInRight" src="images/brushworks_logo.png" alt="brush roller">
      <div class="heroText">
        <h1 id="home-h" class="animated fadeInUp">The Best Painters For Your Home or Business</h1>
        <h2 id="home-p" class="animated fadeInUp">See why we're trusted for over 30 years to service Whidbey Island. Our results speak for themselves</h2>
        <a class="animated fadeInRight href=">Learn More</a>
      </div>
    </div>
  </header>
  <main>
    <!-- ----------------------------------------------------------------------------------- -->
    <!--                                     RED STRIP                                       -->
    <!-- ----------------------------------------------------------------------------------- -->
    <section id="red-strip grid" class="grid">
      <div class="container">
        <div id="strip-1" class="strip-1-center animated slideInUp">
          <div class="flex-1">
            <h3>Residential</h3>
            <p>Our qualified staff are trained to use the techniques and materials that are best suited for each individual home.</p>
          </div>
          <div class="line"></div>
          <div class="flex-1">
            <h3>Commercial</h3>
            <p>No matter what business you're in or how big you facility is, we have the staff and equipment to get it done</p>
          </div>
          <div class="line"></div>
          <div class="flex-1">
            <h3>Interior/Exterior</h3>
            <p>Whether it's inside or out, we have you covered. Our staff can manage any texture and any material</p>
          </div>
        </div>
      </div>
    </section>
    <!-- ----------------------------------------------------------------------------------- -->
    <!--                                     GIVE CALL                                       -->
    <!-- ----------------------------------------------------------------------------------- -->
    <section id="give-call" class="grid">
      <div class="container">
        <div class="st-2-center">
          <h3 class="st-2-call">Give us a call!</h3>
          <h3 class="st-2-number">(360)679-444</h3>
          <p class="st-2-p">We love working on Whidbey Island and the surrounding area. The diverse, eclectic and highly creative customer base keeps our staff and crew challenged and motivated to exceed our customers expectations.</p>
          <a href="#">Contact Us</a>
        </div>
        <div class="st-2-emailus">
          <h4 class="email-us">OR EMAIL US</h4>
          <img src="images/email.jpg" alt="email screen on a phone" width="312" height="140">
        </div>
      </div>
    </section>
    <!-- ----------------------------------------------------------------------------------- -->
    <!--                                     ICON                                            -->
    <!-- ----------------------------------------------------------------------------------- -->
    <section id="icons" class="grid">
      <div class="container">
        <div class="center-3-top">
          <div>
            <h4 class="">OFFERING YOU THE BEST SOLUTION FOR YOUR PROJECT</h4>
          </div>
          <div>
            <p class="">We provide many painting services to our customers. All of our work is performed by our highly qualified staff and backed by our 100% customer satisfaction guarantee.
            </p>
          </div>
        </div>
        <div class="center-3">
          <div class="local">
            <i class="fas fa-map-pin fa-2x"></i>
            <h2>LOCALLY OWNED</h2>
            <p>With over 30 years experience as professional painters, we are one of the largest residential and commercial painting companies on Whidbey Island.</p>
          </div>
          <div class="value">
            <i class="fas fa-dollar-sign fa-2x"></i>
            <h2>BEST VALUE</h2>
            <p>We are confident that we provide the highest quality work for the price. We take great pride in the work we do and refuse to let you pay for work that does not meet expectations.</p>
          </div>
          <div class="qualified">
            <i class="fas fa-medal fa-2x"></i>
            <h2>PROFESSIONALLY QUALIFIED</h2>
            <p>We provide many painting services to our customers. All of our work is performed by our highly qualified staff and backed by our 100% customer satisfaction guarantee.</p>
          </div>
        </div>
      </div>
    </section>
    <!-- ----------------------------------------------------------------------------------- -->
    <!--                                     PARALAX                                         -->
    <!-- ----------------------------------------------------------------------------------- -->
    <section id="paralax" class="grid">
      <div class="paralax-left">

      </div>
      <div class="paralax-right">
        <h3>Any Project,</h3>
        <h3>Any Size</h3>
        <div class="strip-4-p">
          <p class="p-width">Our shop can handle projects from
            <br>small to large. Over that last 30 years we have seen it all and done it all. </p>
          <a class="read" href="#">READ MORE</a>
        </div>
      </div>
    </section>
    <!-- ----------------------------------------------------------------------------------- -->
    <!--                                  CONTACT INFO                                       -->
    <!-- ----------------------------------------------------------------------------------- -->
    <section id="contact-info" class="grid">
      <div class="container">
        <div id="adress">
          <p class="red">Address</p>
          <p class="regular">Brushworks NW <br> 691 Oak St. Unit I <br> Oak Harbor, WA 98277
          </p><br>
          <p class="red">Telephone</p>
          <p class="regular">Tel: (360) 679-4444 <br> Fax: (360) 679-5026
          </p><br>
          <p class="red">Email</p>
          <p class="regular">bwnwinc@gmail.com</p><br>
          <p class="red">Opening Hours</p>
          <p class="regular">Mon - Fri: 7am - 5pm</p>
        </div>
        <div class="form">
          <div>
            <h6>Call Or Email Us Today!</h6>
          </div>
          <form class="container">
            <input class="form" type="text" name="name" placeholder="Full name" style="width: 95%; height: 30px"><br>
            <input class="form" type="text" name="email" placeholder="Email" style="width: 95%; height: 30px"><br>
            <textarea class="form" name="message" placeholder="Message" style="width: 95%; height: 126px"></textarea>
            <input type="submit" value="Send">
          </form>
        </div>
      </div>
    </section>
  </main>
  <!-- ----------------------------------------------------------------------------------- -->
  <!--                                     FOOTER                                          -->
  <!-- ----------------------------------------------------------------------------------- -->
  <footer class="grid">
    <div class="footer container">
      <div class="footer-item">
        <h3>OVER 30 YEARS <br>EXPERIENCE</h3>
        <p>We provide many painting services to our customers. All of our work is performed by our highly qualified staff and backed by our 100% customer satisfaction guarantee. </p>
      </div>
      <div class="footer-item">
        <div class="list">
          <h3 class="adjust">OUR SERVICES</h3>
          <p>- Deck Work</p>
          <p>- Pressure Washing</p>
          <p>- Staining</p>
          <p>- Doors and Cabinets</p>
          <p>- Mill Work Specialists</p>
          <p>- Interior/Exterior Painting</p>
        </div>
      </div>
      <div class="footer-item">
        <h3 class="adjust">ADDRESS</h3>
        <p class="regular">Brushworks NW <br> 691 Oak St. Unit I <br> Oak Harbor, WA 98277
        </p><br>
        <p>Phone: (360) 679-4444 <br> Fax: (360) 679-5026 <br> Email: bwnwinc@gmail.com</p>
      </div>
    </div>
    <div class="facebook container">
      <a href="https://www.facebook.com/brushworksnwinc/"><i class="fab fa-facebook-square fa-2x"></i></a>
    </div>
    <div class="copyright">
      <p class="center">© 2019 Brushworks Inc. NW <br> Designed by <a href="https://www.oakharborwebdesigns.com/">Oak Harbor Web Designs</a></p>
    </div>
  </footer>

</body>

</html>

应该将侧边菜单置于内容的顶部,但div的一部分则不应该。

0 个答案:

没有答案