Flex-box not working in Safari - html

This is SO frustrating. I have tried dozens of "fixes" I am hoping someone can help. I have a flexbox that works well in Chrome and IE, but not Safari (iOS and desktop).
The CSS:
.resulist40 {
list-style: none;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
float:clear;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
height: 350px;
width: initial;
}
.reslist40 {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
min-height: 34px;
}
The HTML:
<ul class="resulist40">
<li class="reslist40">
<a onclick="dovid(1);">Day 1</a>
</li>
<li class="reslist40">
</li>...
</ul>
Here is the desired look (from CHROME):
Here is what it looks like in Safari:

This is my fix, I am not 100% happy. It seems that Safari dosen't work well without having a fixed width - so the flexbox is not really responsive. I found that a width of 130px gives me 3 cols on all browsers.
.resulist40 {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
width: 100%;
padding-left: 10px;
}
.reslist40 {
list-style: none;
display: inline-block;
width: 130px;
height: 34px;
text-align: left;
}

Don't mind me as I dig up this post. I had a similar
misfortune recently but in my case I had...
img {
height: auto;
width: 100%;
}
and Safari was not having it. So I changed it to...
img {
height: 100%;
width: 100%;
}
which made Safari happy again.

Related

masonry layout with css flex not working

I have following situation where css flex based masonry displayed images overflowing the parent div's width. It is supposed to go downwards like a normal Masonry.... but I can't figure it out how to fix this.
I wrote my code like below...
HTML
<div class="mansory-gallery">
<div class="item">
<img src="http://minoboshitaro.com/wp-content/uploads/2017/11/51AEWKP5CQL._SX339_BO1204203200_.jpg">
</div>
</div>
CSS
.mansory-gallery {
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column;
flex-flow: column wrap;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
max-height: 100vw;
flex-direction: column;
}
.item {
width: 28%;
padding: 15px;
margin: 5px;
text-align: center;
display: flex;
flex: 1 1 auto;
}
.mansory-gallery a img {
max-width: 100%;
transition: .8s opacity;
height: auto;
}
Please let me know how to solve this!
Thank you for your time!
Try using justify-content: space-around; instead of margins.
.mansory-gallery {
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column;
flex-flow: column wrap;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
max-height: 100vw;
flex-direction: column;
justify-content: space-around;
}
.item {
width: 28%;
flex-grow: 1;
text-align: center;
display: flex;
flex: 1 1 auto;
}
.mansory-gallery a img {
max-width: 100%;
transition: .8s opacity;
height: auto;
}
Example - https://codepen.io/nhensh/pen/OZRgYa

Flexbox and runat="server" influences and disable flexbox

Aside is used for a complete section left in a webside.
* {
padding: 0px;
margin: 0px;
}
html,
body {
width: 100%;
height: 100%;
color: #00374b;
font-family: Verdana, sans-serif;
font-size: 0.9em;
background-color: #FFFFFF;
}
/*First big flexbox container that places the elements from top to down (column)*/
.flex_container {
width: 100%;
height: 100%;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-direction: column;
-webkit-flex-flow: column;
flex-direction: column;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
}
/*Second big flexbox container for the ASP form from left (aside) to right (main section) (row)*/
.layout_main {
flex: 1 auto;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-direction: row;
-webkit-flex-flow: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
}
.layout_aside {
flex: 1 auto;
background-color: #004664;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-direction: column;
-webkit-flex-flow: column;
flex-direction: column;
padding: 10px;
}
.element {
flex: 1 auto;
}
.layout_main_content {
flex: 1 1 90%;
min-width: 500px;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-direction: column;
-webkit-flex-flow: column;
flex-direction: column;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
}
article{
flex: 1 auto;
}
<body class="flex_container">
<div class="layout_main">
<aside class="layout_aside" id="aside_menu" runat="server">
<div class="element">Test 1</div>
<div class="element">Test 2</div>
<div class="element">Test 3</div>
</aside>
<div class="layout_main_content">
<article>Article1</article>
<article>Article2</article>
</div>
</div>
</body>
For this code the flexbox definition is not working for aside. If I remove the runat="server" the flexbox is again recognized.
Any suggestion or resolution. I tried to put the runat server to a different div but this doesn´t help.

Flexbox, flex-direction: column, image and IE11 bug. Can this be solved?

I have a containing <ul> that is display: flex horizontal. Each <li> is 25% width and also display: flex to get them all equal heights.
Each <li> contains an anchor that is display: flex column, to align the elements within correctly, including the main image container and image. In every browser, including IE10 this is absolutely fine, no issues. However, in IE11 this is where the problems start.
IE11 calculates the image container height as the actual height of the source image, and not the height of the image when rendered. This ends up rendering the <li> much, much taller than it should be.
How the layout looks in every self-respecting browser:
How the layout looks in IE11:
Check out the live example
I know this could be solved by explicitly defining the image height, but I don't want to do that. I could also solve it with JS, but again, I shouldn't have to. Am I missing something with this, as it doesn't appear to be listed on Flexbugs.
* {
box-sizing: border-box;
}
img {
display: block;
width: 100%;
}
.promotions-list {
background-color: #eaeaea;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
padding: .5rem 1rem;
width: 960px;
}
.promotions-list__item {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
padding: 1rem;
width: 25%;
}
.promotions-list__link {
background-color: white;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-flex: 1;
-webkit-flex: 1 1 auto;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
overflow: hidden;
padding: 1em;
position: relative;
width: 100%;
}
.promotions-list .image-container {
display: block;
height: auto;
}
.promotions-list .image-container img {
display: block;
margin: 0 auto;
max-width: 40%;
}
<ul class="promotions-list">
<li class="promotions-list__item has-image">
<a href="/promotion/358/the-new-l5000-mono-laser-range-from-brother" class="promotions-list__link" title="Link to The NEW L5000 Mono Laser Range from Brother details">
<span class="promotions-list__item__header">
<span class="image-container">
<img src="//cdn.2020prosoftware.com/installations/1/promotions/358/original/NewModel2016.png">
</span>
<span class="list__item__title">The NEW L5000 Mono Laser Range from Brother</span>
</span>
<span class="promotions-list__item__body">
<span class="description">The NEW standard in reliability! Introducing new, improved printers from Brother, the market leader…</span>
</span>
</a>
</li>
</ul>
This appears to be fixed by setting flex: 0 0 auto on .promotions-list__item__header.
* {
box-sizing: border-box;
}
img {
display: block;
width: 100%;
}
.promotions-list {
background-color: #eaeaea;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
padding: .5rem 1rem;
width: 960px;
}
.promotions-list__item {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
padding: 1rem;
width: 25%;
}
.promotions-list__link {
background-color: white;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-flex: 1;
-webkit-flex: 1 1 auto;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
overflow: hidden;
padding: 1em;
position: relative;
width: 100%;
}
.promotions-list .image-container {
display: block;
height: auto;
}
.promotions-list .image-container img {
display: block;
margin: 0 auto;
max-width: 40%;
}
/* Added */
.promotions-list__item__header {
flex: 0 0 auto;
}
<ul class="promotions-list">
<li class="promotions-list__item has-image">
<a href="/promotion/358/the-new-l5000-mono-laser-range-from-brother" class="promotions-list__link" title="Link to The NEW L5000 Mono Laser Range from Brother details">
<span class="promotions-list__item__header">
<span class="image-container">
<img src="//cdn.2020prosoftware.com/installations/1/promotions/358/original/NewModel2016.png">
</span>
<span class="list__item__title">The NEW L5000 Mono Laser Range from Brother</span>
</span>
<span class="promotions-list__item__body">
<span class="description">The NEW standard in reliability! Introducing new, improved printers from Brother, the market leader…</span>
</span>
</a>
</li>
</ul>

vertically align content within Chrome

I got a situation where flex box is not working the way I want it to within Chrome but it works in other browsers (apart from iOS mobile devices).
I am struggling to vertically align any content within Chrome but works in everything else. Any ideas?
Also, does anyone know a way I can dynamically stretch a div to a certain % of the div class content which will also work within chrome?
Thanks in advance. See the bottom for demo and screenshots.
HTML
<div class="container">
<div class="content">
<h2>Ticket System <span style="color:#339933; font-weight:bold;">Open</span> Customer Ticket List</h2>
<a class="BlueButton" href="ticket_view_cust_ticket.php">Open Customer Tickets</a>
<a class="BlueButton" href="ticket_view_cust_ticket_rejected.php">Rejected Customer Tickets</a>
<div class="centerContent">
There are currently no open customer tickets
</div>
</div>
</div>
CSS
html,body
{
height: 100vh;
}
body
{
display: table;
margin: 0 auto;
font-family: Tahoma,Arial,Sans-Serif;
}
.container
{
height: 98vh;
vertical-align: middle;
width: 70vw;
min-width:1024px;
margin-left:auto;
margin-right:auto;
margin-top: 1vh;
display: flex;
flex-direction: column;
}
.content
{
background-color: #ff0000;
flex: auto;
webkit-flex-direction: column;
-moz-flex-direction: column;
-ms-flex-direction: column;
-o-flex-direction: column;
flex-direction: column;
webkit-flex-shrink: 0;
-moz-flex-shrink: 0;
-ms-flex-shrink: 0;
-o-flex-shrink: 0;
flex-shrink: 0;
text-align: center;
font-size: 12px;
padding-top:20px;
min-height:600px;
}
.centerContent
{
height: 95%;
padding: 0;
margin: 0;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: center;
}
Demo - https://jsfiddle.net/qr2tpgo6/1/
Container Screenshot - http://prntscr.com/azp8bk
Firefox - http://prntscr.com/azp4oj
Chrome - http://prntscr.com/azp4hy
Your container is missing display: flex, so flex properties aren't working.
Add this:
.content
{
background-color: #ff0000;
flex: auto;
flex-direction: column;
flex-shrink: 0;
text-align: center;
font-size: 12px;
padding-top:20px;
min-height:600px;
display: flex; /* new; establish flex container */
justify-content: center; /* new; center children vertically */
}
Revised Fiddle

Flexbox items order in column

Live link here http://soloveich.com/pr6/blog/
Trying to put date with comments number and post preview in column on mobile screen. Also, bring the date with comments to first place when on mobile screen.
Weridly, it works perfectly on resolution emulators, but nothing happens on phones (iphones and old sgs.)
Html
<div class="postpreview">
<div class="psto"></div>
<div class="datencomments"></div>
</div>
Plus whatever insides
css
.postpreview {
display: flex;
display: -webkit-flex;
display: -moz-flex;
flex-direction:row;
-webkit-flex-direction:row;
-moz-direction:row;
}
.psto {
flex:5;
-webkit-flex:5;
-moz-flex:5;
}
.datencomments {
flex:2;
-webkit-flex:2;
-moz-flex:2;
vertical-align: top !important;
margin-top: 15px;
}
#media screen and (max-width: 380px) {
.postpreview {
display: flex;
display: -webkit-flex;
display: -moz-flex;
flex-direction:column;
-webkit-flex-direction:column;
-moz-direction:column;
}
}
Can't figure out if it's my css (why would it work in emulator then?) or problem with mobile browsers
The majority of mobile browsers only support the old 2009 Flexbox properties. Your code should look like this:
.postpreview {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
.psto {
-webkit-box-flex: 5;
-moz-box-flex: 5;
-webkit-flex: 5;
-ms-flex: 5;
flex: 5;
}
.datencomments {
-webkit-box-flex: 2;
-moz-box-flex: 2;
-webkit-flex: 2;
-ms-flex: 2;
flex: 2;
vertical-align: top !important;
margin-top: 15px;
}
#media screen and (max-width: 380px) {
.postpreview {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
-webkit-box-direction: normal;
-moz-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
}
}
Also note that the default flex-direction is row, so there's no need to specify it unless you're overwriting a previous flex-direction setting.