Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is possible that "display: flex" and "align-items: center" do not work anymore on my iphone?

Hello guys is really strange what happened to me today ... I'm working on a code to create submenus, and I used the property

 display: -webkit-flex;
 display: flex;
 align-items: center;

in this way the voices of the various sections (tags li) are centered vertically. I have used these properties many times before for other codes and they have always worked correctly. As always, I check the code on my mac, on the iPhone 5, on firefox and chrome.

But as soon as I see the file via my iphone 5 (version 8.3) I was shocked .... the properties were not working. I have displayed the old files and even with them the same problem occurred.

The amazing thing is that the mc works wonderfully well with the iPhone 5 to my brother (updated to version 9.x):

I do not understand .... but how is that possible?

It 'a bug? or my iphone is broken?

like image 548
Borja Avatar asked Oct 12 '15 15:10

Borja


People also ask

How do you display flex Items in center?

To center the inner div element we will make the parent a flex container. By adding the display: flex; property we make the section element a flex container allowing us to adjust the layout of the div which is now a flex item. To center out item horizontally we use the justify-content: center; .

How do you center align text in Flex?

All you need to do is add both justify-content: center and align-items:center and flex-direction:column to the Header's CSS rules. You can use this combination of flexbox properties to center any element, not just navbars. Images, divs, etc can all be absolutely centered within a parent element.

How do I align an image to the center in Flex?

How to Center an Image with CSS Grid. CSS Grid works like Flexbox, with the added advantage that Grid is multidimensional, as opposed to Flexbox which is 2-dimensional. To center an image with CSS Grid, wrap the image in a container div element and give it a display of grid . Then set the place-items property to center ...


2 Answers

There is a flexbox bug in Safari:

The <button> and <fieldset> elements can't be flex containers in Safari.

Solution: use a different wrapping element, e.g. an <a> tag.

If you can't or don't want to change the element, you can fix it using box-orient:

display: -webkit-box;
-webkit-box-orient: horizontal;
like image 187
Raymundus Avatar answered Sep 17 '22 22:09

Raymundus


For me to get vertical and horizontal central alignment across Safari and Chrome on iOS and desktop I had to use:

display: flex;
display: -webkit-flex;
justify-content: center;
-webkit-justify-content: center;
align-items: center;
-webkit-align-items: center;
like image 24
Matt Saunders Avatar answered Sep 20 '22 22:09

Matt Saunders