1

Hi I have a parent div main-section and two children div leftContent and rightContent that are placed next to each other.

I want the height of the children to be the same as the parent. Also, I want the main-section to take all the vertical space in the page in case the content in the main-section is not that much. This means that the footer will always remain at the bottom of the page in case of inadequate content.

My code works in Chrome, Safari and firefox but not in IE 11.

JS fiddle - https://jsfiddle.net/2qbw21xk/

This is what is expected -

enter image description here

And this is what happens in IE

enter image description here

Please help!

Thanks in Advance!

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>XXXXXXXXX</title>
        <meta name="description" content="XXXXXXXXXXXXXXXXX">
        <meta name="author" content="XXXXXXXXXXXXXXXXXXXX">
        <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
    </head>
 <style>
 /*----------GLOBAL-------*/
.container{
    width: 97%;
    margin: auto;
    overflow: hidden;
}
.centerAlign{
    text-align: center;
}

/*----------HEADER-------*/
header{
    height: 102px;
}
header div img{
 top: 6px;
 position: relative;
}
.logo_mobile {
    display: none;
}
@media only screen and (max-width: 1100px) {
    .logo_mobile {
    display: inline;
    position: relative;
    top: 25px;
    }
    .logo_desktop {
        display:none;
    }
}
/*----------TOPNAV-------*/
nav {
    background-color: #182d3c;
    color: #fff;
    height: 50px;
    border-bottom: 4px solid #ffd100 !important;
}
nav div ul li{
    display:inline;
}
.navContent{
    position: relative;
    top: 6%;
    height: inherit;
}
/*----------MAIN BODY-------*/
html, 
body {
    height: 100%;
    overflow-x: hidden;
}
.main-section{
 min-height: calc(100% - 291px);
 min-height: -webkit-calc(100% - 291px);
 display: flex;
}
.header{
    border-bottom: 1px solid #e8e8e8;
}
.question{
}
.buttons{/* border-top: 1px solid #e8e8e8; */}

/*---------------RIGHT CONTENT---------------*/

.rightContent{
    overflow: hidden;
    border-left: 1px solid #e8e8e8;
flex:2;
}
/*----LEFT CONTENT---*/
.leftContent{
    float:left;
    flex:7;
}
.header{
}
.buttons{
}
.question{
}

/*----------Footer------*/
footer{
    clear: both;
    position: relative;
    background-color: #e9eef2;
    min-height: 135px;
    width: 100%;
    text-align: center;
}
.footerHead{
    font-weight:400;
    font-size: 20px;
    color: #606d75;
}
/*-----HAMBURGER_____*/
#hamburger_icon{
    float:left;
    height:22px;
    width: 22px;
    display: none;
}

/*----RIGHT PANEL MOBILE-----*/
@media only screen and (max-width: 1100px) {
    .leftContent{
    width:100%;
    }
    .rightContent{
    display:none;}
}

 </style>
    <body>
        <header>
            <div class="container centerAlign">
                <img>
            </div>
        </header>
        <nav>
            <div class="container centerAlign navContent">
                <img src="hamburger.png" id="hamburger_icon">
                <ul>
                    <li>XXX</li>
                    <li>XXX</li>
                    <li>XXX</li>
                </ul>
            </div>
        </nav>
        <section class="main-section">
                <div class="leftContent">
                    <div class="header" id="innerPageHeadingWrap">
                        <P>TITLE SECTION</P>
                    </div>
                    <div class="question">
                        <P>QUESTION SECTION</P>
                        
                    </div>
                    <div class="buttons">BUTTON SECTION
                    </div>
            </div>
                <div class="rightContent">
                    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
                </div>
        </section>
        <footer>
            <div class="footerContent container centerAlign">
            <p>sdf sdfsdfsd fdsfsd fsd fsd f sd f sdf sd fsd f dsfsd</p>
             <p>sdf sdfsdfsd fdsfsd fsd fsd f sd f sdf sd fsd f dsfsd</p>
                </div>
        </footer>
    </body>
</html>
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
Archit Arora
  • 2,508
  • 7
  • 43
  • 69
  • try this https://stackoverflow.com/questions/21600345/flexbox-and-internet-explorer-11-displayflex-in-html – fuzzybear Jan 02 '18 at 00:21

1 Answers1

0

Use flex properties to make the main-section consume all remaining space.

Works across browsers, including IE11.

body {
  display: flex;
  flex-direction: column;
}

header {
  flex: 0 0 102px;    /* can't grow, can't shrink, fixed at 102px height */
}

nav {
  flex: 0 0 50px;
}

.main-section {
  flex-grow: 1;       /* consume all remaining space */
}

footer {
  flex: 1 0 135px;    /* can grow, can't shrink, start at 135px height */
}

revised jsfiddle demo

body {
  display: flex;
  flex-direction: column;
}

header {
  flex: 0 0 102px;
}

nav {
  flex: 0 0 50px;
}

.main-section {
  flex-grow: 1;
}

footer {
  flex: 1 0 135px;
}


/*----------GLOBAL-------*/

.container {
  width: 97%;
  margin: auto;
  overflow: hidden;
}

.centerAlign {
  text-align: center;
}


/*----------HEADER-------*/

header {
  flex: 0 0 102px;
}

header div img {
  top: 6px;
  position: relative;
}

.logo_mobile {
  display: none;
}

@media only screen and (max-width: 1100px) {
  .logo_mobile {
    display: inline;
    position: relative;
    top: 25px;
  }
  .logo_desktop {
    display: none;
  }
}


/*----------TOPNAV-------*/

nav {
  background-color: #182d3c;
  color: #fff;
  height: 50px;
  border-bottom: 4px solid #ffd100 !important;
}

nav div ul li {
  display: inline;
}

.navContent {
  position: relative;
  top: 6%;
  height: inherit;
}


/*----------MAIN BODY-------*/

html,
body {
  height: 100%;
  overflow-x: hidden;
}

.main-section {
  /* min-height: calc(100% - 291px);
  min-height: -webkit-calc(100% - 291px); */
  display: flex;
}

.header {
  border-bottom: 1px solid #e8e8e8;
}

.question {}

.buttons {
  /* border-top: 1px solid #e8e8e8; */
}


/*---------------RIGHT CONTENT---------------*/

.rightContent {
  overflow: hidden;
  border-left: 1px solid #e8e8e8;
  flex: 2;
}


/*----LEFT CONTENT---*/

.leftContent {
  float: left;
  flex: 7;
}

.header {}

.buttons {}

.question {}


/*----------Footer------*/

footer {
  clear: both;
  position: relative;
  background-color: #e9eef2;
  min-height: 135px;
  width: 100%;
  text-align: center;
}

.footerHead {
  font-weight: 400;
  font-size: 20px;
  color: #606d75;
}


/*-----HAMBURGER_____*/

#hamburger_icon {
  float: left;
  height: 22px;
  width: 22px;
  display: none;
}


/*----RIGHT PANEL MOBILE-----*/

@media only screen and (max-width: 1100px) {
  .leftContent {
    width: 100%;
  }
  .rightContent {
    display: none;
  }
}
<header>
  <div class="container centerAlign">
    <img>
  </div>
</header>
<nav>
  <div class="container centerAlign navContent">
    <img src="hamburger.png" id="hamburger_icon">
    <ul>
      <li>XXX</li>
      <li>XXX</li>
      <li>XXX</li>
    </ul>
  </div>
</nav>
<section class="main-section">
  <div class="leftContent">
    <div class="header" id="innerPageHeadingWrap">
      <P>TITLE SECTION</P>
    </div>
    <div class="question">
      <P>QUESTION SECTION</P>

    </div>
    <div class="buttons">BUTTON SECTION
    </div>
  </div>
  <div class="rightContent">
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
      has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
      publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
  </div>
</section>
<footer>
  <div class="footerContent container centerAlign">
    <p>sdf sdfsdfsd fdsfsd fsd fsd f sd f sdf sd fsd f dsfsd</p>
    <p>sdf sdfsdfsd fdsfsd fsd fsd f sd f sdf sd fsd f dsfsd</p>
  </div>
</footer>
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701