Separating divs with a white line to cater to various mobile display sizes

I've put together a simplified version where I removed all styling except for the background color and height for easy visibility. Can anyone shed light on why there is a white line appearing between the divs? It seems to be appearing randomly depending on the screen size. This issue is present in both Chrome and Edge, although I have not tested it in other browsers yet. Initially, I suspected it was an problem with Chrome's mobile viewer, but the same issue persists in Edge as well. Does anyone have insight into what might be causing this or how to fix it? Take a look at the code here. By visiting this link, you can switch between mobile views to observe the issue as shown in the image below.

https://i.sstatic.net/HTrur.png

Answer №1

The reason behind those white lines is the structure of your HTML code. Applying this universal reset might assist in eliminating those white lines.

* { margin: 0; padding: 0; }

Your CSS content could resemble the following:

* {
  margin: 0;
  padding: 0;
}
.main-bottom-div {
  min-height: 35vh;
  background-color: rgb(1, 65, 99);
}
.main-middle-div {
  height: 10vh;
  background-color: rgb(1, 65, 99);
}

I trust this information can be beneficial to you in some capacity. :)

Answer №2

The reason behind this issue remains a mystery to me, but I have discovered a simple workaround. By setting the background color in the parent div and allocating a percentage to each child div as shown below, the problem can be resolved.

.main{
  position: relative;
  height: 100px;
  background: rgba(1, 65, 99, 0.99);
}
.main-bottom-div {
  height: 65%;
}
.main-middle-div {
  height: 45%;
}

<div className={"main"}>
  <div className={"main-middle-div"}>
    <div style={{ padding: "0px 20px" }}>test </div>
  </div>
  <div className={"main-bottom-div"}>
    <div>test</div>
  </div>
</div>

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

Having trouble with loading JavaScript during ng build --prod process

The JavaScript file I'm using for multiple emails (multiple_emails.js plugin) works well with ng serve. Here is my code: (function( $ ){ $.fn.multiple_emails = function(options) { // Default options var defaults = { ...

Custom Component in React Bootstrap with Overflowing Column

I am working on a custom toggle dropdown feature in my React application: import React from 'react'; import 'react-datepicker/dist/react-datepicker.css'; const DateRange = props => ( <div className="dropdown artesianDropdo ...

Stay updated with modifications in array beyond react by subscribing

I am in the process of revamping an old web application that deals with beverage data. To do this, I am integrating React components into the existing legacy system. My goal is to have the React component automatically update whenever a new beverage item ...

What enables typescript to be eligible for transpiling is its equivalent level of abstraction to javascript?

Transpilation is the act of converting code from one language to another with a similar level of abstraction. Can you point out some distinctive characteristics that indicate TypeScript transpires into JavaScript? ...

"Encountering Devextreme Reactive Errors while navigating on the main client

Attempting to integrate Devextreme with Material Ui in my Typescript React app has been a challenge. Despite following the steps outlined in this documentation and installing all necessary packages, I am encountering issues. I have also installed Material ...

Desynchronization of jQuery

Incorporating a slideshow and a function to modify the appearance of four boxes, the following code is utilized: jQuery(document).ready(function() { jQuery('#fp-slides') .cycle({ fx: 'fade', speed: '2500&a ...

Exploring the depths of nested JSON structures with ReactJS

I'm facing an issue while trying to access the nested data from my JSON. The error message that keeps popping up is "Cannot read property 'map' of undefined". I've searched for solutions and watched tutorials, but the problem persists. ...

What causes the checkboxes to shift positions when selected in Safari?

I have encountered an issue with a set of values and checkboxes that are pre-checked on this webpage. Everything seems to be working smoothly in all browsers except for Safari. Whenever I try to click on any of the checkboxes, they seem to 'jump' ...

Customize the background color of a Material UI row with varying colors for each cell

I am facing an issue with a Material UI table in React 18 where each cell has a different background color, causing the hover style on the row to break. Despite trying various solutions, I have been unable to find a resolution. For reference, you can see ...

The homepage on Delphi is having trouble displaying the menus

My issue is not related to resolving a problem with a specific IDE, such as Delphi, but rather about identifying the root cause of the issue. As many of you may be aware, in Delphi 2010 (and possibly in earlier versions), there is a welcome page that displ ...

Vue.js component unable to validate HTML input patterns

Attempting to create HTML forms with the 'pattern' input attribute has been an interesting challenge for me. When implementing this through Vue.js components, I encountered some strange behavior. Check out this fiddle to see it in action. Vue.co ...

Ensuring Smooth Transfer: Sending Local Storage Data to MVC Controller

I'm attempting to send an array of strings from my local storage (key value) to an MVC controller. Here's the code I have so far: Inside the cshtml View file: <script> function getFavouriteBooks() { var ids = JSON.par ...

Incorporating the Material UI App Bar alongside React Router for an enhanced user

For my web development course project, I am venturing into the world of JavaScript and React to create a website. Utilizing Material UI's appbar for my header design, I have successfully incorporated react router to enable navigation on my site. Howev ...

Tips to store Google fonts in the assets directory

I've included this link in my styles.scss @import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap'); While it works locally, the API fails on production or is blocked. How can I host it within my p ...

What Occurs to Processed Messages in Azure Functions if Result is Not Output?

I have created an Azure function that is connected to the messaging endpoint of an IoT Hub in order to trigger the function for all incoming messages. The main purpose of this function is to decompress previously compressed messages using GZIP before they ...

Tips for transferring express route handling to the subsequent middleware and bypassing the current block of code

Here's the current setup of my route handler in my express app: app.use('/', function(res, req, next) => { if (!authorised) next(); f1(); f2(); }); Is there a way to prevent f1() and f2() from running without adding conditional st ...

Can the value of an object parameter be inserted dynamically?

I've been racking my brain over this, but so far I haven't found a solution that fits my exact issue. My query is about the feasibility of entering a value for an object parameter from an input box dynamically? For instance: <form name= ...

CSS - Implementing two stylesheets sequentially in an Opencart website

Currently, I am encountering a frustrating issue on my website. The CSS files are loading in a peculiar order - first the default styles, followed by my custom overrides in luke.css. This results in a brief display of cream color on the left sidebar before ...

What is the best way to navigate through the underlying MatDialog while the MatSelect is active?

When attempting to customize the scroll behavior of a MatSelect in a regular page, I discovered that using the MAT_SELECT_SCROLL_STRATEGY injection token with the NoopScrollStrategy allows for scrolling the underlying page while keeping the MatSelect stati ...

At times, PHP mail usage may result in certain $_POST arrays being unexpectedly empty

I've encountered an issue while using the php mail function to send data from a html form. The mail function is functioning correctly and I receive the email upon form submission, but occasionally I receive empty arrays in the email content. Here is ...