Why does Flex-layout create odd gaps in spacing that are not present in Edge?

Trying to create a scrollable-table using flexbox.
The challenge is to fit a table with fixed sizes into a viewport of specific dimensions.
Here's the basic structure I have in mind:

<div class="container" style="width: x; height: y; overflow: scroll">
   <div data-row="1">
       <div data-column="1"></div>
       <div data-column="2"></div>
       <div data-column="3"></div>
   </div>
   <div data-row="2">
       <div data-column="1"></div>
       <div data-column="2"></div>
       <div data-column="3"></div>
   </div>
   <div data-row="3">
       <div data-column="1"></div>
       <div data-column="2"></div>
       <div data-column="3"></div>
   </div>
</div>

Current progress looks like this:

#viewport {
  border: 1px solid black;
  overflow: auto;
  width: 350px;
}

#content {
  #position: relative;
  overflow: hidden;
}

.cell {
  display: flex;
  flex-shrink: 0;
  flex-grow: 0;
  flex-wrap: nowrap;
  overflow: hidden;
  box-sizing: border-box;
}

.column {
  width: 200px;
  height: 100px;
}

.row {
  display: flex;
  flex-direction: row;
  overflow: hidden;
  border: 1px solid black;
  #overflow-x: scroll;
  overflow: visible;
  box-sizing: border-box;
}

.viewport {
  display: flex;
  flex-direction: column;
  width: 300px;
  height: 500px;
  overflow: scroll;
  flex-wrap: wrap;
  #flex-wrap: nowrap;
  box-sizing: border-box;
  flex-basis: 0;
}
<div class="viewport"><<!--
        --><div class="row"><<!--
            --><div class="cell column" style="background-color: red;"></div><<!--
            --><div class="cell column" style="background-color: green;"></div><<!--
            --><div class="cell column" style="background-color: blue;"></div><<!--
            --><div class="cell column" style="background-color: hotpink;"></div><<!--
        --></div><<!--
        --><div class="row"><<!--
            --><div class="cell column" style="background-color: red;"></div><<!--
            --><div class="cell column" style="background-color: green;"></div><<!--
            --><div class="cell column" style="background-color: blue;"></div><<!--
            --><div class="cell column" style="background-color: hotpink;"></div><<!--
        --></div><<!--
    --></div> 

Encountering white space issues, particularly on Chrome and IE11 - whereas Firefox and Edge are working correctly.
Removing flex-wrap property from .viewport causes similar problems on Edge and Firefox.
Ideally, I'd prefer not having the flex-wrap on .viewport altogether.

The root cause of this discrepancy eludes me thus far.
Frustrating situation indeed. Any insights or suggestions would be greatly appreciated.

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

Answer №1

The issue is explained in relation to the CSS Box Model:

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

source: W3C

It's important to note that a border only applies to the border area of an HTML element, not extending into the overflow area beyond the margin area. This explains why borders may appear truncated when scrolling into the overflow area.

Browser behavior can vary as it's based on guidelines rather than strict rules. Developers have the freedom to deviate from specifications as needed.

For further insight, refer to this post addressing the similarities between background-color and overflow behaviors compared to border and overflow: Make background color extend into overflow area

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

Persistent footer overlaps lower body content

Issue with Sticky Footer in Safari I recently added a sticky footer to my website, but I'm facing problems with it covering the body content on Safari. It works fine on Chrome and Firefox after adding a bottom margin to the body to adjust for the hei ...

Utilize Bootstrap's table-hover feature in combination with rowspan to effectively highlight every row associated with a specific

I am attempting to replicate the functionality of the table-hover class on a Bootstrap table that contains multiple cells with different rowspan values. This means I want to highlight every cell within the same row. Below is an example demonstrating the cu ...

Injecting dynamic data into a function parameter with Angular 1 Interpolation

In my code, I have a feature that alters the text displayed on a button depending on certain conditions. $scope.text = 'Wait'; if(Number($scope.x) == Number($scope.y)) $scope.text = 'Go' else if(Number($scope.x) < Number($scope ...

React Application - The division is positioned centrally when run on local host, however, it does not retain its center alignment

I'm encountering an issue with deploying my create-react-app on github pages. The first image showcases my deployed app on github pages, but the image is not properly centered on the page as intended. https://i.stack.imgur.com/rOciT.jpg On the othe ...

Access the value retrieved from a form on the previous page using PHP

I'm struggling with extracting values from radio buttons on a previous page. Currently, my HTML and PHP code works fine with the search bar, which is the first form below. However, I'd like to add radio button filters below the search bar. <s ...

The Electron app is experiencing issues with updating the edited index.html file properly

Recently, I decided to delve into learning Electron and as a beginner, I decided to clone a simple electron tutorial app to experiment with its features. (The official Electron starter app worked perfectly for me). The GitHub repository I used: https://gi ...

Adjust the size of the flex item based on the background image dimensions

Within a flexbox, there are flex items displayed Each flex item should appear as a clickable folder with specific text inside It seems that the only CSS way to achieve this is by using a background image. However, I want to accomplish the following: Cons ...

Revamp the md-select Container

Hello there! I'm looking for a stylish way to revamp the design of the md-select Window. Specifically, I aim to customize the background and hover effects. Despite my attempts to modify the .md-select-menu-container in CSS, it proved unsuccessful. I ...

"Text data will be automatically cut at the end of a page and continue

I encountered the following issue As depicted in the image The data is not being displayed properly In the next td, the last character 3 is also printed on the next line Is it possible to avoid page footer and header without adjusting the page margin? ...

Problem with CSS in the Internet Explorer 8 browser encountered

While working on a project, I encountered an unexpected design issue on a client's machine that has Internet Explorer 8 installed. Interestingly enough, when testing on my own machine with IE 9 and using F12 to switch to compatibility mode for IE 8/7, ...

Changing the appearance of a sibling element when a checkbox is selected

JSX code demo: <input type="checkbox" defaultChecked={myfilter.includes("Banana")} /> <span onClick={onClickHandler} className="banana">Banana </span> HTML equivalent code : `<input type=& ...

Issues detected with Foundation Block Grid in small size setting

I created a React component to display a series of div elements on a page using the Foundation Block Grid system to control the number of divs per row. However, I am facing an issue where the number of divs does not change when switching to a small-sized s ...

Is there a way I can implement jQuery animation on my pop-up window?

I've successfully set up a basic popup using jQuery. When a button is clicked, it changes the 'display' property of a div from 'none' to 'block' in CSS and creates an overlay to darken the background. Take a look at my c ...

What is the best way to implement coding for portrait styles specifically on the Kindle Fire device?

Any recommendations on how to specifically code the styles for portrait orientation solely on the Kindle Fire device? ...

Pictures glide within containers

Hey, I'm having an issue with my images. They're not floating like they should be, even though they are centered in the div. I really want them to float and be centered. Here's the code snippet I've been working with. HTML <div cla ...

Is it possible for me to route a URL to a particular content generated by Ajax on a separate webpage?

I appreciate anyone taking the time to help with this, especially since I already had to get 12 stitches. Here's what I'm dealing with: mysite.com/documentation - page with a menu and content section (content will load dynamically via Ajax w ...

Interacting with API using Ajax and jQuery

I am struggling to get my simple jQuery request to work correctly. I'm not sure what I'm doing wrong. Can you help me identify the error? http://jsfiddle.net/k6uJn/ Here is the code snippet: $(document).ready(function() { $.ajax({ type: "G ...

Learn the position of a div element that appears following the lazy loading of images

I am struggling to make a div sticky below a set of lazy load images. The issue lies in the fact that the offset of the div keeps changing due to the lazy loading images pushing it down. There are 4 images with unknown heights, making it difficult to acc ...

What is the mistake in my update function when working with nodejs and mongodb?

Greetings! I am a beginner in using nodejs and mongodb, and I am looking to create a function that updates the win, lose, and draw record in my userschema. Here is my Schema: UserSchema = new mongoose.Schema({ username:'string', passwor ...

Strange occurrences with CSS in a pair of Divs

I am currently facing an issue with the alignment of two div elements in my HTML web page. The first div acts as a header at the top with a height of 77px and contains dropdown menus. Below this, I have the second div that I want to center align with a wid ...