如何修复各节之间的空白?

时间:2019-06-03 19:37:40

标签: css responsive-design removing-whitespace

我从移动优先设计入手,但在删除办公空间时遇到了一些问题。顶部的两个div之间和主体右侧有空白。您怎么删除它们?

我尝试过使用隐藏在身体上的overflow-x =,但无法固定右侧的空白。

我还将body和html的边距设置为0-仍然无效。

要固定div之间的空间,我将div之间的边距清零,在主体上使用display = initial和display = inline,尝试使用position top属性并将其实际向上移动,但不会让步,我尝试调整div的大小-无效。

.container {
  padding: 0 1em;
}

body,
html {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Raleway', sans-serif;
  text-align: center;
  overflow-x: hidden;
}


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

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

.navbar-links {
  display: none;
}

#logo {
  display: none;
}

.open-slide {
  float: right;
  margin-top: 25px;
  margin-right: 20px;
  display: block;
  z-index: 4;
}

.side-nav {
  width: 0;
  display: none;
  height: 100%;
  position: absolute;
  top: 0;
  background-color: #fff;
  transition: 0.5s;
  right: -1px;
  text-align: right;
  z-index: 15;
  margin-top: 10%;
}

#side-hidden {
  background-color: #000;
  opacity: 0.9;
  height: 100%;
  position: absolute;
  top: 0;
  transition: 0.5s;
  left: 0 margin: 0;
  width: 0;
  z-index: 6;
}

.side-nav ul {
  display: block;
  text-decoration: none;
  z-index: 6;
  /* Added this */
  padding: 0;
  position: relative;
  top: -8%;
  list-style: none;
}


/* Added this */

.nav-item {
  display: block;
  margin: 0;
}

.side-nav ul a {
  position: relative;
  width: 100%;
  /* Changed this */
  /* padding: 10px 130px 10px 100px;*/
  padding: 20px 15px;
  text-decoration: none;
  color: #000;
  margin-right: 20px;
  z-index: 6;
  /* Removed this */
  /* right: 30px; */
  text-align: right;
  /* Added these */
  display: block;
  box-sizing: border-box;
}

.btn-close {
  display: block;
  background: #fff;
  position: absolute;
  top: 0;
  /* Changed this */
  /* left: 22px; */
  left: 0;
  font-size: 36px;
  text-decoration: none;
  color: #ccc;
  right: 7px;
  top: -10px;
}

.btn-close {
  background: #fff;
  color: #000;
  position: relative;
  padding: 0;
  margin: 0;
}

.btn-close a:hover {
  color: #444;
  cursor: pointer;
  background: #fff;
}

.side-nav .btn-close:hover {
  color: #fff
}

.side-nav li a:hover {
  color: #fff;
  background: #CE2026;
}

.side-active {
  color: #ffffff !important;
  background: #CE2026;
}

.mobile-logo {
  position: relative;
  margin-left: 35%;
  margin-right: 50%;
  z-index: 5;
  top: -3.25em;
}


/*-- -------------------------------------------- -->
<!--              HERO STRIP                      -->
<!-- -------------------------------------------- -*/

#hero {
  height: 410px;
  width: 100%;
  position: relative;
  top: -38px;
  background: url("https://imgur.com/NwkADjO") no-repeat center center fixed;
  padding: 0;
  margin: 0;
  color: #fff;
}

#home-h {
  width: 100%;
  font-weight: 900;
  font-size: 2.7em;
  padding-top: .8em;
  line-height: 1em;
}

#home-p {
  font-size: 1.25em;
  padding-bottom: .8em;
  font-weight: 350;
  animation-delay: 0.3s;
  margin: 0;
}

.learn {
  display: inline-block;
  border-style: solid;
  border-width: 2px;
  border-color: #FFFFFF;
  font-size: 17px;
  margin: 20px 0;
  padding: 18px 65px;
  color: #FFFFFF;
  text-decoration: none;
  animation-delay: 0.6s;
}

.heroText a:hover {
  background: #fff;
  border-color: #fff;
  color: #CE2026;
  transition: background 0.4s ease 0s;
  transition-property: background;
  transition-duration: 0.4s;
  transition-timing-function: ease;
  transition-delay: 0s;
  cursor: pointer;
}


/*-- -------------------------------------------- -->
<!--              RED STRIP                       -->
<!-- -------------------------------------------- -*/

#red-strip {
  background: #CE2026;
  color: #fff;
  height: 500px;
  padding: 0;
  margin: 0;
  float: left;
}

.strip-1-center {
  padding: 1.8em;
}

.strip-1-center h3 {
  padding-top: 1em;
}


/*-- -------------------------------------------- -->
<!--              GIVE CALL                       -->
<!-- -------------------------------------------- -*/

#give-call {
  margin: 0;
  padding: 0;
  height: 100%;
}
<!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>
    <img class="mobile-logo container" src="https://imgur.com/YjFzHVf" width="91px" height="91px">
    <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>
  </nav>
  <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="#" id="btn-close" 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>
  <main>
    <section 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="learn animated fadeInRight href=">Services</a>
        </div>
      </div>
    </section>
    <!-- -------------------------------------------- -->
    <!--              RED STRIP                       -->
    <!-- -------------------------------------------- -->
    <section id="red-strip" 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="give-call-number">
          <h3 class="gcn-call">Give us a call!</h3>
          <h3 class="gcn-number">(360)679-444</h3>
          <p class="gcn-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="give-call-email">
          <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>
    </div>
  </footer>
  <script>
    function toggleNav() {
      document.getElementById("side-menu").style.width = "50%";
      document.getElementById("side-menu").style.display = "block";
      document.getElementById("side-hidden").style.width = "60%";
      document.getElementById("noScroll").style.overflow = "hidden";
      document.getElementById("btn-close").style.color = "#000000";
      document.getElementById("btn-close").style.background = "white";
    }

    function closeSideMenu() {
      document.getElementById("side-menu").style.width = "0";
      document.getElementById("side-hidden").style.width = "0";
      document.getElementById("noScroll").style.overflow = "scroll";
      document.getElementById("btn-close").style.background = "white";
      document.getElementById("btn-close").style.color = "#CE2026";
    }
  </script>
</body>

</html>

0 个答案:

没有答案