1

I can't seem to make min-height work. The main problem is, my child doesn't get height of parent, thus doesn't set its own height. How can i fix this?

#middle_Wrapper {
  width: 100%;
  min-height: 85vh;
  max-height: 500%;
  height: auto;
}

#main {
  width: 90%;
  height: 100%;
  background-color: red;
  opacity: 0.2;
  position: relative;
}
<div id="middle_Wrapper">
  <main id="main">
     test
  </main>
</div>
Arjan Knol
  • 942
  • 5
  • 20
Dassin
  • 107
  • 1
  • 6

2 Answers2

4

Change height : auto to height : 0

#middle_Wrapper {
  width: 100%;
  min-height: 50vh;
  max-height: 500%;
  height: 0; /* change this line */
}

#main {
  width: 90%;
  height: 100%;
  background-color: red;
  opacity: 0.2;
  position: relative;
}
<div id="middle_Wrapper">
  <main id="main">
     test
  </main>
</div>
Pascal Goldbach
  • 977
  • 1
  • 15
  • 34
0

Just add css, you are using % so change it into vh.

#main {
  height: 100vh;
}

#middle_Wrapper {
  width: 100%;
  min-height: 50vh;
  max-height: 500%;
  height: auto;
}

#main {
  width: 90%;
  height: 100vh;
  background-color: red;
  opacity: 0.2;
  position: relative;
}
<div id="middle_Wrapper">
  <main id="main">
     test
  </main>
</div>
LKG
  • 4,152
  • 1
  • 11
  • 21
  • Uhh, the main problem is, i forgot to add i wan't the div to expand as more and more HTML text is added, that applies to parent. – Dassin Jun 02 '17 at 11:22