The issue with CSS3 flex-wrap not functioning properly on Safari and Chrome in IOS 10.1.1

My goal is to create a dynamic grid layout using flex wrap and min-width: 50%, where each cell should occupy the entire width. However, I'm encountering an issue in iOS 10.1.1 (iPhone 5c) Safari and Chrome where the display is not grid-like but rather a horizontal layout. Interestingly, the layout works correctly in desktop Chrome (Ubuntu) and Android Chrome.

You can view the Jsfiddle demo here: https://jsfiddle.net/9dscc1Lq/

Here's the code snippet:

<style>

body {
    width: 300px;
}

.tabs {
    width: 100%;
    display: flex;
    display: -webkit-flex;
    flex-wrap: wrap;
    -webkit-flex-wrap: wrap;
    flex: 0 0 auto;
    -webkit-flex: 0 0 auto;
    box-sizing: border-box;
    flex-flow: row wrap;
    -webkit-flex-flow: row wrap;
}

.tab {
    border: 1px solid #3A3A3A;
    color: #929292;
    min-width: 50%;
    box-sizing: border-box;
    flex: 1 1 0;
    -webkit-flex: 1 1 0;
    text-align: center;
}

</style>

<div class="tabs">
    <div class="gwt-HTML tab">1</div>
    <div class="gwt-HTML tab">2</div>
    <div class="gwt-HTML tab">3</div>
    <div class="gwt-HTML tab">4</div>
    <div class="gwt-HTML tab">5</div>
</div>

Expected layout (correct):

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

iOS behavior (incorrect): https://i.sstatic.net/4D9oi.png

Your insights on how to resolve this issue would be greatly appreciated!

Answer №1

On iOS, the usage of <code>min-width
does not perform as expected; instead, try utilizing flex-basis in this format: flex: 1 1 50%;

Source:

Additionally, it is advisable to always place prefixed properties before the unprefixed versions when implementing them.

.tabs {
  width: 100%;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  box-sizing: border-box;
}
.tab {
  border: 1px solid #3A3A3A;
  color: #929292;
  box-sizing: border-box;
  -webkit-flex: 1 1 50%;
  flex: 1 1 50%;
  text-align: center;
}
<div class="tabs">
  <div class="gwt-HTML tab">1</div>
  <div class="gwt-HTML tab">2</div>
  <div class="gwt-HTML tab">3</div>
  <div class="gwt-HTML tab">4</div>
  <div class="gwt-HTML tab">5</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

In the Xcode 12, SceneKit won't automatically cover the entire screen

I've been experimenting with SceneKit and developing iOS games. I'm currently using Xcode 12 Beta 5, but no matter what I try, the SceneView doesn't fill up the screen when I start a game with SceneKit's default code. Interestingly, whe ...

Tips on how to achieve a 50% width within a bootstrap input group

Need help setting the width of a select tag <div class="input-group"> <select class="form-select" style="width: 50%;"> <option selected value="dummy">Dummy</option> <opt ...

Retrieve and decode JSON data using Swift

It's puzzling why this isn't functioning correctly... whenever I run it, an error appears in the console: [CONNECTION] OK, data properly downloaded [ERROR] There was a parsing error with the json data nil Perhaps it's the JSON format in th ...

Tips for effectively overlaying one container on top of another in a responsive manner

There are a pair of containers. The main container functions as the parent, while the child container acts as a tag to categorize the content. The objective is to position the tag container at the top right corner of the main content container, slightly of ...

`After the initial instance, the menu title will be altered.`

I have a responsive menu using Bootstrap. When the menu is collapsed, I want it to display the name of the page, and when it is open, I want it to show "Menu." Currently, I have named it "Watch the Trailer" (so let's assume that we are on that page). ...

The concept of nested classes in HTML involves styling the innermost class using CSS

When dealing with 3-4 nested classes in HTML, what is the most effective method for targeting the innermost class when applying CSS styles? <div class="head"> <form class="newmem"> <input type="text" name"Firstname" value="First Name"> & ...

Guide on aligning a division within another division?

Included below is my HTML code: <div id="background_div"> <img id="background_img" src="images/background.jpg" alt="dont matter"> <i class="material-icons">perm_identity</i> <div id="dropdown"> <ul id=" ...

JS: Ensure to scroll down once the div element has been "unhidden"

Within a div element, I have an abundance of content: <div id="x" class="unhidden"> text and additional divs </div> The CSS class 'unhidden' is defined as: display: block; Upon clicking a link, the element with the id='x& ...

XSL:include is failing to function properly

Here is the configuration I have set up: <?xml version="1.0"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:include href="top.xsl"/> <xsl:template match=""> Content will be placed here - i ...

Image expansion

I have a container element div that holds various content of unknown length. How can I add a background image that extends the entire length of the container since background-images do not stretch? I attempted to use a separate div with an img tag inside. ...

Make sure the image is aligned in line with the unordered list

I've been having trouble trying to display an image inline with an unordered list. Here's the HTML code: <div class="customer-indiv man"> <a class="customer_thumb" href="/fan/332profile.com"> <img src="http://i.imgur.com/Wi ...

Is it possible to animate share buttons using Framer Motion but staggering siblings?

I have a Share Icon that looks like: I'm looking to display the first 5 icons, with the 5th icon being the share icon. The remaining icons should appear below the share icon and expand to the right when someone taps or hovers over it (either tap or h ...

Choosing different elements using identical classes in JQuery

Struggling with a coding problem that seems like it should be an easy fix, but can't quite figure it out. The HTML code I have is as follows: <section class="actualite"> <div class="actualite-text"> <h3 class="title"&g ...

Can you explain the distinction between the View and TableView properties in a UITableViewController?

Upon delving into Apple's documentation, I stumbled upon some intriguing information. Within UIViewController, the view property is described as: @property(nonatomic, retain) UIView *view This signifies the view that the controller oversees. Furth ...

Globalization for dynamically generated text

I'm looking for assistance on how to internationalize programmatically created strings. Specifically, I have a simple method that creates an alert. func loginAlert(viewController : UIViewController , callback: (result: Bool) -> ()) { var a ...

Alter the color of Material UI Raised Button when it is hovered over

I am trying to change the background color of a raised button on hover in Material UI. I attempted the following, but it did not work. Is there a way to modify the background color in Material UI for a raised button? Example.JS <RaisedButton ...

Ways to display an icon with an underline effect upon hovering over text

I have implemented a CSS effect where hovering over text creates an underline that expands and contracts in size. However, I now want to display an icon alongside the text that appears and disappears along with the underline effect. When I try using displa ...

Dropdown menu similar to the one utilized in Bootstrap

I am curious to understand how the drop-down menu system in Bootstrap3's tutorial page operates. It seems that it collapses all subtopics under a main topic by default, allowing users to either click or scroll to expand further. Additionally, the menu ...

Is there a way to temporarily halt a CSS animation when it reaches the final frame

Can anyone assist me with getting the "-webkit-animation-fill-mode: forwards;" to work? It seems like it's getting stuck on the first frame, and I can't figure out why. JS FIDDLE <div class="logo"></div> .logo { width: 328px; ...

Not every situation calls for the same type of styling

I am struggling to override the CSS for <h1> and <h2> using specific selectors only. The changes are only being applied to one class, with <h1> changing color to green but not <h2>. Can someone please assist me in identifying where ...