[html] How do I make flex box work in safari?

How do I make flex boxes work in Safari? I have a responsive nav that uses a CSS flex box to be responsive and for some reason it won't work in Safari.

Here is my code:

_x000D_
_x000D_
#menu {_x000D_
 clear: both;_x000D_
 height: auto;_x000D_
 font-family: Arial, Tahoma, Verdana;_x000D_
 font-size: 1em;_x000D_
 /*padding:10px;*/_x000D_
 margin: 5px;_x000D_
 display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */_x000D_
 display: -moz-box;    /* OLD - Firefox 19- (buggy but mostly works) */_x000D_
 display: -ms-flexbox;  /* TWEENER - IE 10 */_x000D_
 display: -webkit-flex; /* NEW - Chrome */_x000D_
 display: flex;         /* NEW, Spec - Opera 12.1, Firefox 20+ */_x000D_
 justify-content: center;_x000D_
 -webkit-box-align: center;_x000D_
 -webkit-flex-align: center;_x000D_
 -ms-flex-align: center;_x000D_
 -webkit-align-items: center;_x000D_
 align-items: center;fffff_x000D_
 font-style: normal;_x000D_
 font-weight: 400px;_x000D_
}_x000D_
#menu a:link {_x000D_
 display: inline-block;_x000D_
 width: 100px;_x000D_
 height: 50px;_x000D_
 padding: 5px;_x000D_
 background-color: yellow;_x000D_
 /*border: 1px solid #cccccc;*/_x000D_
 margin: 5px;_x000D_
 display: flex;_x000D_
 flex-grow: 1;_x000D_
 align-items: center;_x000D_
 text-align: center;_x000D_
 justify-content: center;_x000D_
 font-weight: bold;_x000D_
 color: #1689D6;_x000D_
 font-size: 85%;_x000D_
}_x000D_
#menu a:visited {_x000D_
 display: inline-block;_x000D_
 width: 100px;_x000D_
 height: 50px;_x000D_
 padding: 5px;_x000D_
 background-color: yellow;_x000D_
 /*border: 1px solid #cccccc;*/_x000D_
 margin: 5px;_x000D_
 display: flex;_x000D_
 flex-grow: 1;_x000D_
 align-items: center;_x000D_
 text-align: center;_x000D_
 justify-content: center;_x000D_
 font-weight: bold;_x000D_
 color: #1689D6;_x000D_
 font-size: 85%;_x000D_
}_x000D_
#menu a:hover {_x000D_
 display: inline-block;_x000D_
 color: #fff;_x000D_
 width: 100px;_x000D_
 height: 50px;_x000D_
 padding: 5px;_x000D_
 background-color: red;_x000D_
 /*border: 1px solid #cccccc;*/_x000D_
 margin: 5px;_x000D_
 display: flex;_x000D_
 flex-grow: 1;_x000D_
 align-items: center;_x000D_
 text-align: center;_x000D_
 justify-content: center;_x000D_
 font-weight: bold;_x000D_
 font-size: 85%;_x000D_
}_x000D_
#menu a:active {_x000D_
 display: inline-block;_x000D_
 color: #fff;_x000D_
 width: 100px;_x000D_
 height: 50px;_x000D_
 padding-top: 5px;_x000D_
 padding-right: 5px;_x000D_
 padding-left: 5px;_x000D_
 padding-bottom: 5px;_x000D_
 background-color: red;_x000D_
 /*border: 1px solid #cccccc;*/_x000D_
 margin: 5px;_x000D_
 display: flex;_x000D_
 flex-grow: 1;_x000D_
 align-items: center;_x000D_
 text-align: center;_x000D_
 justify-content: center;_x000D_
 font-style: normal;_x000D_
 font-weight: bold;_x000D_
 font-size: 85%;_x000D_
}
_x000D_
<nav id="menu">_x000D_
  <a href="#">Philadelphia</a>_x000D_
  <!--<a href="#">Vacation Packages</a>-->_x000D_
  <a href="#">United States of America</a>_x000D_
  <a href="#">Philippines</a>_x000D_
  <a href="#">Long Destinations Names</a>_x000D_
  <a href="#">Some Destination</a>_x000D_
  <a href="#">Australia</a>_x000D_
</nav>
_x000D_
_x000D_
_x000D_

http://jsfiddle.net/cyberjo50/n55xh/3/

Is there a prefix I'm missing to make it work in Safari?

This question is related to html css safari flexbox

The answer is


It works when you set the display value of your menu items from display: inline-block; to display: block;

See your updated code here:

#menu {
    clear: both;
    height: auto;
    font-family: Arial, Tahoma, Verdana;
    font-size: 1em;
    /*padding:10px;*/
    margin: 5px;
    display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
    display: -moz-box;    /* OLD - Firefox 19- (buggy but mostly works) */
    display: -ms-flexbox;  /* TWEENER - IE 10 */
    display: -webkit-flex; /* NEW - Chrome */
    display: flex;         /* NEW, Spec - Opera 12.1, Firefox 20+ */
    justify-content: center;
    -webkit-box-align: center;
    -webkit-flex-align: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center;fffff
    font-style: normal;
    font-weight: 400px;
}

#menu a:link {
    display: block; //here you need to change the display property
    width: 100px;
    height: 50px;
    padding: 5px;
    background-color: yellow;
    /*border: 1px solid #cccccc;*/
    margin: 5px;
    display: flex;
    flex-grow: 1;
    align-items: center;
    text-align: center;
    justify-content: center;
    font-weight: bold;
    color: #1689D6;
    font-size: 85%;
}
#menu a:visited {
    //no display property here                                                                       
    width: 100px;
    height: 50px;
    padding: 5px;
    background-color: yellow;
    /*border: 1px solid #cccccc;*/
    margin: 5px;
    display: flex;
    flex-grow: 1;
    align-items: center;
    text-align: center;
    justify-content: center;
    font-weight: bold;
    color: #1689D6;
    font-size: 85%;
}
#menu a:hover {
    //no display property here                                                                               
    color: #fff;
    width: 100px;
    height: 50px;
    padding: 5px;
    background-color: red;
    /*border: 1px solid #cccccc;*/
    margin: 5px;
    display: flex;
    flex-grow: 1;
    align-items: center;
    text-align: center;
    justify-content: center;
    font-weight: bold;
    font-size: 85%;
}
#menu a:active {
    //no display property here                                                                               
    color: #fff;
    width: 100px;
    height: 50px;
    padding-top: 5px;
    padding-right: 5px;
    padding-left: 5px;
    padding-bottom: 5px;
    background-color: red;
    /*border: 1px solid #cccccc;*/
    margin: 5px;
    display: flex;
    flex-grow: 1;
    align-items: center;
    text-align: center;
    justify-content: center;
    font-style: normal;
    font-weight: bold;
    font-size: 85%;
}

Demo -> https://jsfiddle.net/xdsuozxf/

Safari still requires the -webkit- prefix to use flexbox.

_x000D_
_x000D_
.row{_x000D_
    box-sizing: border-box;_x000D_
    display: -webkit-box;_x000D_
    display: -webkit-flex;_x000D_
    display: -ms-flexbox;_x000D_
    display: flex;_x000D_
    -webkit-flex: 0 1 auto;_x000D_
    -ms-flex: 0 1 auto;_x000D_
    flex: 0 1 auto;_x000D_
    -webkit-box-orient: horizontal;_x000D_
    -webkit-box-direction: normal;_x000D_
    -webkit-flex-direction: row;_x000D_
    -ms-flex-direction: row;_x000D_
    flex-direction: row;_x000D_
    -webkit-flex-wrap: wrap;_x000D_
    -ms-flex-wrap: wrap;_x000D_
    flex-wrap: wrap;_x000D_
}_x000D_
_x000D_
.col {_x000D_
    background:red;_x000D_
    border:1px solid black;_x000D_
_x000D_
    -webkit-flex: 1 ;-ms-flex: 1 ;flex: 1 ;_x000D_
}
_x000D_
<div class="wrapper">_x000D_
      _x000D_
    <div class="content">_x000D_
        <div class="row">_x000D_
            <div class="col medium">_x000D_
                <div class="box">_x000D_
                    work on safari browser _x000D_
                </div>_x000D_
            </div>_x000D_
            <div class="col medium">_x000D_
                <div class="box">_x000D_
                    work on safari browser _x000D_
                    work on safari browser _x000D_
                    work on safari browser _x000D_
                    work on safari browser _x000D_
                    work on safari browser _x000D_
                </div>_x000D_
            </div>_x000D_
            <div class="col medium">_x000D_
                <div class="box">_x000D_
                    work on safari browser _x000D_
                    work on safari browser _x000D_
                    work on safari browser _x000D_
                    work on safari browser _x000D_
                    work on safari browser _x000D_
                    work on safari browser  work on safari browser _x000D_
                    work on safari browser _x000D_
                </div>_x000D_
            </div>_x000D_
        </div>   _x000D_
    </div>_x000D_
</div>
_x000D_
_x000D_
_x000D_


Maybe this would be useful

-webkit-justify-content: space-around;

Try this:

select {
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -ms-flexbox;
}

Giving flex a value solved the problem for me, e.g.

flex: 1 0 auto

Just tRy this

display: -webkit-box;   /* OLD - iOS 6-, Safari 3.1-6, BB7 */
display: -ms-flexbox;  /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Safari 6.1+. iOS 7.1+, BB10 */
display: flex;         /* NEW, Spec - Firefox, Chrome, Opera */

this worked for me


display: flex;
display: -webkit-box;

did it for me. Also there were two display: flex; on the same element from different classes. So I removed the other one.


Just try -webkit-flexbox. it's working for safari. webkit-flex safari will not taking.


I had to add the webkit prefix for safari (but flex not flexbox):

display:-webkit-flex


Examples related to html

Embed ruby within URL : Middleman Blog Please help me convert this script to a simple image slider Generating a list of pages (not posts) without the index file Why there is this "clear" class before footer? Is it possible to change the content HTML5 alert messages? Getting all files in directory with ajax DevTools failed to load SourceMap: Could not load content for chrome-extension How to set width of mat-table column in angular? How to open a link in new tab using angular? ERROR Error: Uncaught (in promise), Cannot match any routes. URL Segment

Examples related to css

need to add a class to an element Using Lato fonts in my css (@font-face) Please help me convert this script to a simple image slider Why there is this "clear" class before footer? How to set width of mat-table column in angular? Center content vertically on Vuetify bootstrap 4 file input doesn't show the file name Bootstrap 4: responsive sidebar menu to top navbar Stylesheet not loaded because of MIME-type Force flex item to span full row width

Examples related to safari

How to Inspect Element using Safari Browser What does the shrink-to-fit viewport meta attribute do? background: fixed no repeat not working on mobile Swift Open Link in Safari How do I make flex box work in safari? onClick not working on mobile (touch) window.open(url, '_blank'); not working on iMac/Safari HTML5 Video tag not working in Safari , iPhone and iPad NodeJS/express: Cache and 304 status code Video auto play is not working in Safari and Chrome desktop browser

Examples related to flexbox

Force flex item to span full row width vuetify center items into v-flex Equal height rows in CSS Grid Layout display: flex not working on Internet Explorer Center the content inside a column in Bootstrap 4 Vertical Align Center in Bootstrap 4 How to use zIndex in react-native Bootstrap 4 align navbar items to the right Does 'position: absolute' conflict with Flexbox? Make flex items take content width, not width of parent container