Exploring the varying flexbox behavior with (overflow-y) scroll on Safari, Firefox, and Edge compared to Chrome

When viewing this plunker page on Chrome for Windows and Android (including Canary), everything functions properly. I am able to scroll the two areas on the left and right, and the top and bottom divs of the page remain at the top and bottom of the device screen at all times. However, when attempting to view the page on iPad or iPhone using Safari or Chrome, as well as on Firefox 47.0.1 for Windows, the display is different.

The page is lengthy, yet there is only one scroll bar on the right, almost as if the flexbox code is being ignored:

.bigone {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.main {
    flex: 1 1 0;
    display: flex;
}
.container-fluid {
  display: flex;
}
.col-6 {
  overflow-y: auto;
}

Issue Example:

You can observe the discrepancy on iPad or iPhone by clicking on this button:

Why is this happening? Is it a bug in Safari and Firefox or Chrome? Why does it work fine on Chrome for Windows and Android? If the issue is resolved in future versions of Safari, how can we handle older devices with older iOS and Firefox versions?

Any insight or assistance on this matter would be greatly appreciated. Thank you.

Answer №1

Dealing with this issue can be quite frustrating and puzzling.

The root cause of this problem in similar scenarios typically lies in the minimum sizing algorithm on flex items. These regulations, specified in the rules, prevent a flex item from shrinking below the size of its content. As a result, when the content cannot overflow a flex item, a scrollbar cannot be displayed, and the item simply expands instead.

Despite attempting standard methods to override this behavior (e.g., min-height: 0, overflow: hidden), none seem to be effective in this particular case.

Here are a couple of recommendations that may bring you closer to a resolution:

(1) To ensure the entire layout fits within the viewport without a vertical scrollbar on the browser window, avoid using min-height to size the container. Instead, specify a fixed height.

To make this adjustment to your code:

.bigone {    
    display: flex;
    /* min-height: 100vh;   <-- REMOVE */
    height: 100vh;       /* <-- NEW   */
    flex-direction: column;
}

However, this modification alone may not completely solve the issue.

(2) A straightforward and swift solution to this problem is to assign a height to .col-6.

Include the following in your code:

.col-6 {
    height: 90vh;
 }

Hence, it seems that Edge, Firefox, and other browsers experiencing issues require a defined height on that specific container.

revised demo

Answer №2

Michael_B's response just didn't cut it. When dealing with a dynamic header, footer, and other divs, the 90vh solution falls short.

To address this issue (albeit temporarily, until Safari addresses it), I added the following to the parent div:

min-height: 100vh; height: 100vh;

Additionally, I included

flex: 1; min-height: 0;' on the initial children.

Nonetheless, something still feels off.

Answer №3

Consider this approach:

justify-content: center;

This CSS property can be applied to the flex-item for achieving the desired result. It worked for me, possibly due to the magic of center...

Sharing this discovery as other options like max-width, text-align, etc... were not consistently effective for me either.

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

Interactive menu backdrop determined by div element

I am working on a website with a menu structured like the following: Home -- Work -- Pricing -- Contact Us -- About This website uses a one-page layout and has enabled Scrollspy on Bootstrap. I need to make the active menu background dynamic depending o ...

Enhancing the appearance of unvisited links with background styles

I am endeavoring to incorporate an icon into all unvisited links on a specific Wordpress category page. Below is the CSS code that I am utilizing. It has been placed at the conclusion of my final CSS file. .category-xyzzy .entry-title a:link { background ...

The table borders in IE 11 do not display properly when using Html5 and CSS

In a previous version, the table had visible borders. However, when I added the property text-align:center; to my container, the table did not align to the center. I then tried adding display:inline-block; to the table, which successfully centered it. It l ...

Troubleshooting issues with Jquery fadeIn and fadeOut - tips for implementing fadein animation using addclass and mouseover

My concept involves a shop menu displayed as a list: <li class="shop-menu"><a href="{{url('shop')}}">shop</a></li> When the shop-menu is hovered over (using a mouseover jquery function), I aim to make a div named shop-m ...

Tips on effectively utilizing CSS sprites without a border on images

I am currently working on optimizing my website by using sprite images. The image I am using is in png format and looks like this: https://i.sstatic.net/pFhPq.png Here is a snippet of my CSS code: .bg-upperbar_1 { width: 55px; height: 55px; bac ...

Angular2 application encounters issue with target attribute being overlooked by Chrome

I am trying to implement a link in an iframe following the instructions on W3Schools: <iframe height="300px" width="100%" src="demo_iframe.htm" name="iframe_a"> </iframe> <p><a href="http://www.w3schools.com" target="iframe_a">W3S ...

Protecting against overflow for text inside a container that changes when hovered over

There is text displayed on top of an image within a div container that functions as a link. <a href="https://link.com" style="color:white"> <div class="thumbnail"> <img src="image.jpg" clas ...

Slider Volume with jQuery

Struggling to find a solution for this issue. Seeking some assistance. My goal is to create a basic volume slider. So, the orange section represents my volume slider. This is the jQuery code I am using: var mouseIsDown = false; $("#volSlider").on("mou ...

Placing a crimson asterisk beside the input field within Bootstrap

Trying to insert a red * at the end of my input field using bootstrap, but all my attempts so far have been unsuccessful. Is there a way to align the Currently experiencing this issue: https://i.stack.imgur.com/61pzb.png Code snippet: .required-after ...

When resizing the browser, HTML/CSS elements tend to shift positions :(

I've experimented with different position values like absolute, fixed, and static without success. Wrapping the element in a div didn't yield the desired result, so I'm seeking assistance to correct this. (If that is the solution) The issu ...

Looking to eliminate a significant gap of white space

I have been scouring the internet for hours, gathering a lot of information, but unfortunately, I haven't found exactly what I'm looking for. I have implemented this specific code in my WordPress website Additionally, I have integrated infinite ...

Is the scaling of a div with an image affected by odd pixel sizes?

My goal is to create a responsive grid with square images, where the first image is double the size of the others. While I can achieve this using jQuery, I am curious if there's a way to accomplish this purely with CSS. Grid: Here's an example o ...

Updating Text within a Label with jQuery

Seeking assistance with a jQuery issue that I am struggling to resolve due to my limited experience. Despite attempting to search for solutions online, I have been unable to find an alternative function or determine if I am implementing the current one inc ...

Simplified user interface for detecting radio button clicks

Currently working on a form that includes radio buttons, where an update function is triggered whenever there is a user input change. The challenge I am facing is how to incorporate user-friendly radio buttons with a larger button area encompassing both t ...

Utilizing CSS attr() for setting the width dimension

I'm having some trouble setting the width of an element using attr() in CSS. Chrome keeps giving me an "invalid property value" error and I can't figure out what's causing it. What I'm attempting to do is use the attribute "prog" as th ...

What is the best way to have text fit perfectly into a table cell?

In my asp.net table, the first column contains captions for each row of data. The length of these captions varies, with different amounts of words in each one. I am looking to align the first letters of each caption at the beginning edge of the cells (left ...

Customize the Underline Color in MaterialUI Select Component

I'm experimenting with MaterialUI and trying to figure out how to customize the underline and text color of the Select component when an item is selected. Currently, the underline and label appear blue after selection with a gray background. Is there ...

Creating a custom blockquote style for a WordPress Twenty Fifteen child theme

Currently, I am creating a new child theme for Twenty Fifteen completely from scratch. The one area I am struggling with is customizing the appearance of the blockquote using CSS. Here is an example of the custom CSS I have added to the blockquotes within ...

Utilizing Extjs to incorporate a display field with an image as a label

I need help figuring out how to create a display field with an image label instead of a text label, without having to create a custom class. I am aware that I could use an hbox container with an image and the xtype: label, but I am hoping to utilize the xt ...

Can you explain the purpose of CSS classes such as my-2, my-lg-0, and mr-sm-2 in Bootstrap 4?

I have searched through various questions and the Bootstrap documentation but haven't been able to determine the purpose of these classes on elements. Any assistance would be greatly appreciated! My goal is to adjust my search bar's size to 1/4th ...