-
Notifications
You must be signed in to change notification settings - Fork 495
IE11: align-items: center with min-height workaround #231
Comments
I just ran into the same issue (IE11/Windows 10). @pcgilday, thanks for the workaround with smaller |
Hmmm, really interesting solution, but it appears like this doesn't work in all cases. I tried it on my sticky footer demo and it doesn't work if the window is smaller than the content: |
Very simple workaround - https://codepen.io/arsentver/pen/eywEzK?editors=1100 |
Very helpful, thank you! 👍 |
@philipwalton I hit that issue as well. I wanted a min-height of 75vh, but sometimes the content got taller than that. I got around it with: |
@Abby805 IE11 doesn't support max-content simple example:
|
@arsentver Thanks for the tip, I would add |
Actually, if you set min-height to a flex container, you have to set the height to it as well on IE11. .flex-container { It works for me. There is a same vertical align issue for bootstrap modal before v4.*. It already be fixed in latest version with a pseudo-class for IE11. .modal-dialog-centered::before { |
@arsentver your solution work to me very easily really great! thanks so much |
* Fixing IE11 flexbox alignment when min-width is set For more info on the fix please see philipwalton/flexbugs#231 * Updating the IE11 alignment fix Updating the fix to use philipwalton/flexbugs#231 (comment) approach for cases with larger cover image text. * Documenting the code * chore: Tweak code style * Add display: block, remove Github ticket mention. * Ignore the IE11 cover image fix in browsers that support flex. * Add a better description of the IE fix. * Fix typo.
This just saved my life. THANK YOU! |
Thanks @pcgilday, this fix is like a magic tricks :D |
Tried a few solutions for this mentioned above to no avail. I might have got something wrong or it might just be the project set up with polyfills for IE11. Anyway what worked for me in the end for IE11 was to wrap my flex container (the parent of stuff I wanted to vertical align i.e. with I believe DmitriyKurto suggested this as well. Thanks for that. I've had enough flexing for one day. |
Awesome solution! 🤩👍 I only think, that the after-element is missing |
@yevgenysim this solution does not allow the container to expand when the child is higher than 500px. It is the same as if you just set |
Thank you @pcgilday, this is great. Works like a charm, even To avoid any unexpected issues with other browsers I would limit this to IE10 and 11 only, like: .container {
display: flex;
align-items: center;
justify-content: space-between;
background-color: gray;
min-height: 4em;
height: 2em;
}
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
/* IE10+ CSS styles go here */
.container {
height: 1px;
}
} |
I believe this is related to flexbug 3, but I found the below workaround more useful in the scenario we encountered this bug.
Bug: Setting
min-height
breaksalign-items: center
in ie11. You can setheight
explicitly, but in some situations you wantmin-height
notheight
. In our situation this was desired so that the child items can stack and increase the height if needed.Workaround: Setting
height
to a value less thenmin-height
fixes thealign-items: center
issue in IE11, but the container still sets its size based onmin-height
, effectively giving you the desired behavior.I've tested this workaround in chrome 59, safari 10, and FF 64, and IE11, it is only needed in IE11, but works with all tested browsers.
codepen: https://codepen.io/pcgilday/pen/BdNRVO (see comments in css, uncomment line called out to see workaround)
SO response that led me to workaround: https://stackoverflow.com/a/25386261/3886141
microsoft issue: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/101414/ - this was closed as duplicate, but the duplicate mentioned is specifically for
flex-direction: column
, so I left a comment there with this info to see if they agree or I'm missing something.I'm happy to open a PR with this workaround if you agree it is a acceptable for this situation. Thank you for maintaining this list, it has helped us a ton!
The text was updated successfully, but these errors were encountered: