Flexbox IE10 width issues - css

The problem is that in IE10, the width of the columns inside the row is being calculated wrong, it appears to be adding on the width of the column margins (in total 80px), but in Firefox and Chrome it calculates it perfectly and fits everything inside 1260px. The main issue is that i have prefixed everything in what i believe is the right way, but i still get the issue.
You can see it here on jsFiddle - http://jsfiddle.net/andyjh07/ue2zfga6/
CSS:
.row {
width: 100%;
position: relative;
background: red;
display: box;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: flex;
box-orient: vertical;
-webkit-flex-direction: column;
-moz-flex-direction: column;
flex-direction: column;
-ms-flex-direction: column;
margin-bottom: 40px; }
.row:after {
content: "";
display: table;
clear: both; }
.row *[class^="col-"] {
position: relative;
display: block;
height: auto; }
.row *[class^="col-"]:first-child {
margin-left: 0; }
#media (min-width: 64em) {
.row {
box-orient: horizontal;
-webkit-flex-direction: row;
-moz-flex-direction: row;
flex-direction: row;
-ms-flex-direction: row; } }
#media (min-width: 78.75em) {
.row {
max-width: 78.75em;
margin: 0 auto; } }
.col-one-third {
width: 100%;
background: blue; }
#media (min-width: 64em) {
.col-one-third {
width: 33.3%;
margin-left: 40px; } }
.col-two-thirds {
width: 66.7%;
margin-left: 40px;
background: blue; }
How it looks on Chrome, IE11, Firefox
How it looks on IE 10, emulated inside IE11's dev console/tools
As you can see, the margin's are being added and going beyond the width of the container

I don't have IE10 available, but it seems like you should look at caniuse.com and the known issues. Or maybe this user moderated list on Github. Or maybe the comment section of the css-tricks guide.
The caniuse site mentions:
IE10 and IE11 default values for flex are 0 0 auto rather than 0 1 auto, as per the draft spec, as of September 2013.
and
In IE10 and IE11, containers with display: flex and flex-direction: column will not properly calculate their flexed childrens' sizes if the container has min-height but no explicit height property.
The Github site mentions:
When using align-items:center on a flex container in the column direction, the contents of flex item, if too big, will overflow their container in IE 10-11.
Workaround
Most of the time, this can be fixed by simply setting max-width:100% on the flex item. If the flex item has a padding or border set, you'll also need to make sure to use box-sizing:border-box to account for that space. If the flex item has a margin, using box-sizing alone will not work, so you may need to use a container element with padding instead.
This comment on css-tricks shows that where you would normally say flex: 1; you should say -ms-flex: 1 0 auto;
Also, you should change your code where it does something like this:
-webkit-flex-direction: column;
-moz-flex-direction: column;
flex-direction: column;
-ms-flex-direction: column;
to this:
-webkit-flex-direction: column;
-moz-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
You always want the proper line of code—the one without flags— at the bottom of the prefix list.

Related

Flexbox wrap - first and last item displaying incorrectly on iPad

I am having an issue with flexbox wrap on iPad. When emulating iPad in Chrome developer tools I get the result I want, all the items wrapping and displaying correctly. However, when I test using Browserstack on a physical iPad the first and last item inside the flex container do not behave the same, please see the images below for comparison.
Dev Tools iPad Emulation
Browserstack iPad / Physcial Device
I have been browsing other peoples solutions on here but to no avail. Here is the SASS snippet with solutions people have provided on other questions added, but still not working. Have also added a link to the page in question below so it can be inspected easier.
This is my Css
.blogPageCards {
display: flex;
flex-wrap: wrap;
flex-direction: row;
.articleCard {
flex-direction: column;
width: calc(50% - 30px);
margin: 0px 15px;
&:before {
display: none;
content: normal;
}
&:after {
display: none;
content: normal;
}
}
}
http://nevillejohnson.dev.clicky.co.uk/inspiration/
Please let me know if you need any more information. Thanks in advance.
As i am unable to write comment, i am writing it here.
I think it is not working because your browser(i assume it is IOS Safari)needs css vendor prefix to implement the flexbox.
I am unsure which IOS Safari version is your Ipad using but if it is between 3.2 - 6.1 you surely must put -webkit- before the flexbox like this
.blogPageCards {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
.articleCard {
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
width: calc(50% - 30px);
margin: 0px 15px;
&:before {
display: none;
content: normal;
}
&:after {
display: none;
content: normal;
}
}
}

Can't get flexbox to work in IE/Safari

This all works perfectly in Chrome on my MBP, but breaks endlessly on the other browsers. I have used, https://autoprefixer.github.io/ to generate the necessary prefixes but to no avail.
Maybe someone can spot where I am going wrong? I striped the prefixed code out because I don't know what is affecting what now, so it's a bit of a blank slate... Heres the code and associated screenshots
Code is modified because of so many diff nested div's in here. Order will be parent > child etc..
.recommendation-modal {
display: flex;
justify-content: flex-start;
flex-direction: row;
align-items: flex-start;
background: #FFFFFF;
z-index: 202;
width: 100%;
max-width: 800px;
height: 70vh;
.rec-right--container {
display: flex;
flex-direction: column;
flex: 1;
width: 100%;
height: 100%;
background-color: #4B77BE;
color: #fff;
.rec-right--body {
display: -moz-flex;
display: -webkit-flex;
display: -ms-flex;
display: flex;
-moz-flex-direction: column;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
padding: 20px;
height: 100%;
#media (max-width: $screen-sm) {
flex-direction: row;
}
Ended up just needing to add the old syntax, I basically just found every old syntax possible and threw them in there until it worked...

Scrollable items outside of scroll container; Invisible scroll container

I have container with buttons on top of a map control. This control needs to be scrollable as there might be more buttons than the screen height allows for.
What I am looking for is a way to have the buttons to be displayed outside of the container which means that I can put the container off the screen to be invisible.
Or to have the scrollbar on the left hand side so that it is not between the map and the controls.
Here is some html
<div class='ctrl__scroll'>
<button class="map__interface mdl-button mdl-js-button mdl-button--fab mdl-button--colored">
<i class="material-icons">add</i>
</button>
<button class="map__interface mdl-button mdl-js-button mdl-button--fab mdl-button--colored">
<i class="material-icons">remove</i>
</button>
<button>...</button>
</div>
Here is the css
.ctrl__scroll {
position: absolute;
top: 0;
left: 0;
width: 90px;
height: 100%;
overflow-y: auto;
overflow-x: hidden;
background-color: rgba(0, 0, 0, 0.5);
}
.ctrl__scroll > .mdl-button {
margin-top: 10px;
margin-left: 10px;
}
Here is the jsFiddle for the screenshot.
https://jsfiddle.net/goldrydigital/zez3gz21/
Edit: I have now worked this out and changed the jsFiddle. I am using the excellent jScrollPane plugin which allows me to do whatever I want with scrollpanes.
Even if you could display the children outside their scrollable parent (which is counter-intuitive at best) I don't think you'd be able to scroll them. However, you can't have overflow-x:visible; overflow-y:auto; on the same an element. It will automatically add a scrollbar for the X asis too.
Let's take into account that most mobile devices have nice-looking, self-hiding semi-transparent bars, making your solution look good even with the scrollbar visible (as it is now). We only need to fix the scrollbar on non-touch devices. On desktop devices, which are rendering it ugly and opaque. Here's a possible solution:
#media (min-width: 768px) {
.ctrl__scroll > .mdl-button {
margin: 10px 0 0 10px;
}
.ctrl__scroll {
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-moz-box-orient: vertical;
-moz-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-pack: start;
-webkit-justify-content: flex-start;
-moz-box-pack: start;
-ms-flex-pack: start;
justify-content: flex-start;
overflow: visible;
background-color: transparent;
}
}
Add it at the end of your current CSS. Your updated jsFiddle.
Just add:
.map {
padding-left: 90px;
...
}
which is the size of your side menu

Nested flexbox adds empty space on IE10 and 11

I'm using flexbox for a layout. My constraint is that the image must be situated at the middle.
I've made a minimal markup that reproduces the issue: http://codepen.io/anon/pen/xwNomN
It works perfectly well in all browsers EXCEPT on IE 10 and 11, where (as shown in the CodePen) a big amount of empty space is added at the top and bottom of the image.
.collection__list {
display: flex;
flex-wrap: wrap;
}
.product-item {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.product-item__figure {
position: relative;
display: flex;
align-items: center;
justify-content: center;
flex: 1 0 auto;
}
.product-item__figure > a {
display: flex;
position: relative;
flex: 1;
}
.product-item__image-wrapper {
position: relative;
width: 100%;
}
.product-item__image {
display: block;
margin: 0 auto;
max-width: 100%;
}
I've tried a lot of fixes, played with flex-shrink, flex-grow... but after 1 whole day lost, I'd love to know what I'm doing wrong.
Thanks
Oh... I've found it by chance. Adding overflow: hidden to product-item__figure made the trick....

CSS flexbox not working in IE10

In IE10, this code isn't working correctly:
.flexbox form {
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: -o-flex;
display: flex;
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
}
.flexbox form input[type=submit] {
width: 31px;
}
.flexbox form input[type=text] {
width: auto;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: -o-flex;
display: flex;
-webkit-flex: auto 1;
-moz-flex: auto 1;
-ms-flex: auto 1;
-o-flex: auto 1;
flex: auto 1;
}
What should happen is that input[type=submit] should be 31px wide, with input[type=text] taking up the rest of the available space within form. What happens is input[type=text] just defaults to 263px for some reason.
This works fine in Chrome and Firefox.
Flex layout modes are not (fully) natively supported in IE yet. IE10 implements the "tween" version of the spec which is not fully recent, but still works.
https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes
This CSS-Tricks article has some advice on cross-browser use of flexbox (including IE):
http://css-tricks.com/using-flexbox/
edit: after a bit more research, IE10 flexbox layout mode implemented current to the March 2012 W3C draft spec: http://www.w3.org/TR/2012/WD-css3-flexbox-20120322/
The most current draft is a year or so more recent: http://dev.w3.org/csswg/css-flexbox/
As Ennui mentioned, IE 10 supports the -ms prefixed version of Flexbox (IE 11 supports it unprefixed). The errors I can see in your code are:
You should have display: -ms-flexbox instead of display: -ms-flex
I think you should specify all 3 flex values, like flex: 0 1 auto to avoid ambiguity
So the final updated code is...
.flexbox form {
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: -o-flex;
display: flex;
/* Direction defaults to 'row', so not really necessary to specify */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
}
.flexbox form input[type=submit] {
width: 31px;
}
.flexbox form input[type=text] {
width: auto;
/* Flex should have 3 values which is shorthand for
<flex-grow> <flex-shrink> <flex-basis> */
-webkit-flex: 1 1 auto;
-moz-flex: 1 1 auto;
-ms-flex: 1 1 auto;
-o-flex: 1 1 auto;
flex: 1 1 auto;
/* I don't think you need 'display: flex' on child elements * /
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: -o-flex;
display: flex;
/**/
}
IE10 has uses the old syntax. So:
display: -ms-flexbox; /* will work on IE10 */
display: flex; /* is new syntax, will not work on IE10 */
see css-tricks.com/snippets/css/a-guide-to-flexbox:
(tweener) means an odd unofficial syntax from [2012] (e.g. display: flexbox;)

Resources