Skip to content

Instantly share code, notes, and snippets.

@AlexWebLab
Last active August 16, 2016 09:31
Show Gist options
  • Save AlexWebLab/d6374a26a872837e0b6cc365931b8249 to your computer and use it in GitHub Desktop.
Save AlexWebLab/d6374a26a872837e0b6cc365931b8249 to your computer and use it in GitHub Desktop.
In IE 10-11, min-height declarations on flex containers work to size the containers themselves, but their flex item children do not seem to know the size of their parents. They act as if no height has been set at all.
ul, li { margin: 0; padding: 0; }
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
.flexbox_wrapper_ie_10_11_fix {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
}
}
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
.flexbox_wrapper_ie_10_11_fix {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>IE 10-11 flexbox min-height fix</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link href="flexbox_wrapper_ie_10_11_fix.css" rel="stylesheet">
</head>
<body>
<div class="flexbox_wrapper_ie_10_11_fix">
<ul style="min-height: 100vh; display: flex; justify-content: space-around; align-items: center;">
<li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li>
</ul>
</div><!-- /.flexbox_wrapper_ie_10_11_fix -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment