I am experiencing an issue with my divs displaying an undesired white border on mobile screens

Having a challenge with the layout of my website when viewed on mobile devices or in Chrome's developer mobile tools. The two divs at the top of the page are producing a thin white border, which is not visible in regular browser view.

Initially faced the issue with the divs containing Lorem Ipsum content when the body had a background color set. Upon research, found that adding a background color to the body triggers this problem. Removing the background color from the body resolved the white outlines on those divs but caused them to appear in the navbar instead.

Attempts to fix the issue by setting margins, padding, and borders to 0, as well as using outline:none, have been unsuccessful so far.

* {
  box-sizing: border-box;
  margin: 0px;
  padding: 0px;
  outline: none;
  border: 0px;
}

.left_logo_nav {
  display: flex;
  width: 50%;
  align-items: center;
  height: 86px;
  background-color: #0D6AE8;
}

.main-nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  background-color: #0D6AE8;
  height: 86px;
  width: 50%;
}

.box {
  display: flex;
  flex-wrap: wrap;
}

.gap {
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 975px;
  background-color: #0D6AE8;
}
<body>
  <div class="box">
    <div class="left_logo_nav">
      <a href="index.html"><img class="top_logo" src="svg/franco_logo.svg" alt="Logo" /></a>
    </div>

    <nav class="main-nav">
      <li class="no-bullet"><a class="nav-text" href="#about">About</a></li>
      <li class="no-bullet"><a class="nav-text" href="portfolio.html">Portfolio</a></li>
      <li class="no-bullet"><a class="nav-text" href="#">Climate</a></li>
      <li class="no-bullet"><a class="nav-text" href="contact.html">Contact</a></li>
    </nav>

  </div>
  <div class="gap"></div>
</body>

Answer №1

To eliminate the white line, set the Box div as the outer div and assign a background-color to this class.

* {
  box-sizing: border-box;
  margin: 0px;
  padding: 0px;
  outline: none;
  border: 0px;
}

.left_logo_nav {
  display: flex;
  width: 50%;
  align-items: center;
  height: 86px;

}

.main-nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;

  height: 86px;
  width: 50%;
}

.box {
  display: flex;
  flex-wrap: wrap;
  background-color: #0D6AE8;
}

.gap {
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 975px;

}
<body>
  <div class="box">
    <div class="left_logo_nav">
      <a href="index.html"><img class="top_logo" src="svg/franco_logo.svg" alt="Logo" /></a>
    </div>

    <nav class="main-nav">
      <li class="no-bullet"><a class="nav-text" href="#about">About</a></li>
      <li class="no-bullet"><a class="nav-text" href="portfolio.html">Portfolio</a></li>
      <li class="no-bullet"><a class="nav-text" href="#">Climate</a></li>
      <li class="no-bullet"><a class="nav-text" href="contact.html">Contact</a></li>
    </nav>
  <div class="gap"></div>
</div>
</body>

Answer №2

I couldn't pinpoint the exact cause of those narrow lines surrounding my divs on mobile view, but experimenting with different sizing units did make a slight difference.

To address this issue, I decided to create a container for the three divs instead of coloring each one individually. By adding the background color to the container, I was able to eliminate the unwanted lines.


       <div class="section_1">

         <div class="box">

           <div class="left_logo_nav"><a href="index.html"><img class="top_logo" 
           src="svg/franco_logo.svg" alt="Logo"/></a></div>

            <nav class="main-nav">
              <li class="no-bullet"><a class="nav-text" href="#about">About</a></li>
              <li class="no-bullet"><a class="nav-text" 
              href="portfolio.html">Portfolio</a></li>
              <li class="no-bullet"><a class="nav-text" href="#">Climate</a></li>
              <li class="no-bullet"><a class="nav-text" 
              href="contact.html">Contact</a> 
              </li>
            </nav>

          </div>

          <div class="gap"></div>

        </div>

As for the CSS adjustments, I removed the individual background-color properties and applied it to the .section_1 class instead.


            .section_1 {
                background_color: #0D6AE8;
            }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The iframe is not large enough to contain all the HTML content

I'm encountering a problem with a website I'm currently developing - specifically, I am struggling to embed an HTML document into an iframe in a manner that fills the entire page. Additionally, I am utilizing Angular to retrieve the HTML document ...

What is the best way to display the panel during a postback?

I have a group with two radio buttons labeled purchase and expenses. When the purchase radio button is clicked, the panelpurchase will be displayed, and similarly, the panelexpense will show for the expenses radio button. Check out the image of the output ...

How can I navigate through all the divs by setting an interval slider with a random starting point?

I have a Jsonp request that returns a block of HTML with the following structure: <div id="slider_wrapper" style=""> <div style="xxx" ><section style="xx">xx</section></div> <div style="xxx" ><section style=" ...

What is the best way to define a margin according to the size of the device being used

I am working on an angular/bootstrap web app and need to set a left margin of 40px on md, xl, lg devices and 0px on sm device. I attempted to create a spacer in styles.scss like this: $spacer: 1rem; .ml-6{ margin-left:($spacer*2.5); } Then in my HTML, ...

Obtain meta title and description using JavaScript

I'm having trouble retrieving the meta title and description from websites entered into the URL field. When I input a URL and click fetch, nothing appears. However, when I hardcode "https://www.espn.com/" in the JS function, it pulls in the entire web ...

Unable to modify the width of textarea

I've been struggling to adjust the width of a textarea element, as neither setting rows and cols in HTML nor using CSS has worked for me. The height adjustment was successful with HTML. Any tips on changing the width? form, label { position: rel ...

Guide to presenting fields on a distinct line or section in Angular 7 forms

I would like to arrange the username area and password area on separate lines with spaces in between. Here is the HTML code snippet: This HTML code is for a login angular GUI. <mat-card class="card"> <mat-card-content> <!-- CONT ...

What is the best way to create a triangle shape that is responsive to elements?

I'm trying to make a background shape with a triangle inclusion using CSS. I want it to be responsive to all screen sizes, but I'm having some trouble. Any tips on how to achieve this? header { width: 100%; height:150px; background: #eee; } m ...

Exploring the process of implementing a filter search feature using Vue.js and JavaScript

Is it possible to create a filter search code using just data and method functions? I attempted to do the following: var fil = new Vue ({ el: '#app', data: { search: '', proL: [&a ...

What is the technique for adding a stroke to an SVG border?

I am in the process of creating a gauge component using SVG. I'm using two strokes to show two states simultaneously. Currently, my output looks like this: enter image description here enter image description here However, I would like it to look li ...

Dynamic fields added using JavaScript are not recognized by PHP

I have a MySQL database where orders are stored along with various activities. My PHP/HTML page retrieves these activities when an order is clicked and allows users to modify them using a form. Upon submission, another PHP file updates the database by loop ...

Why does the jQuery hide function fail to work on a div with the same class after an ajax

1. I'm encountering an issue with my code. I have a div class "inner" which is being dynamically loaded via an ajax call. However, after the ajax call, if I click the hide button, it doesn't work. Strangely, it was working perfectly fine before ...

Enable the script tag with the type "module" only under certain conditions

Attempting to dynamically enable script tags in HTML using the code below does not yield the expected results. function loadScript() { document.querySelectorAll('script[type="text/skip-hydration"]').forEach((script) => { script ...

Insert between the top navigation bar and the sidebar menu

I am currently in the process of designing my very first website and I have encountered a bit of trouble. I would like to add a page between a navbar and a vertical bar, and I want this page to be displayed when a button on the vertical bar is clicked. You ...

How can I align a button in the center using Bootstrap 4?

<div class="container"> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-8"> <div v-for="job in job"> <div class="text-center"> <h1>{{ job.job_title }}</h1> <p> ...

Tips for fixing the position without affecting the width

I'm trying to figure out how to keep my #header fixed in position without it expanding in width. Despite checking my code multiple times, I can't seem to identify the factor causing my header to become wider and shift downwards unexpectedly. I in ...

Tips for transferring parameters using a href tag without causing a page refresh

Is there a way to pass parameter values without refreshing the page? I would appreciate any help. Thank you. searchresult.php <a href="index.php?id=<?php echo $data['ID']?>">clickme</a> index.php <?php echo $_GET['id ...

Using the Jquery load function to add new content to existing HTML

I'm attempting to create an AJAX request that will insert additional HTML content into the existing content within specified tags. Below is the structure of my load function. <script> $(document).ready(function(){ $(".tid-select").cha ...

Ways to design siblings that are not currently being hovered over

Is there a way to achieve an effect where hovering over one list item causes all other list items to fade out? I'm searching for a method to style an element that is not being hovered, when one of its siblings is in the hovered state. I've trie ...

The form-group nested within a form-horizontal is exceeding the boundaries of the preceding form-group

I am currently utilizing Bootstrap 3.3.6 and have a basic form enclosed in a panel: https://i.stack.imgur.com/UOFI6.png Although it is quite simple, the alignment of the "Post" button is not displaying properly. Here is the HTML code for the form: < ...