html - CSS How to position div inside div so that it will always be 100% -


using css property 'position', how possible make div inside div 100% height of parent div, margin of 40px on top , on bottom? needs adjusting, if parent div 700px in height, child div 620px (700px - 80px margins). here example of mean:

here parent div (green) tall, child (orange) must stretch fit space.

and here parent (green) squashed, child (orange) must compensate squashing fit.

thank in advance.

edit:

here html im working with:

<div id="center-page">     <p id="center-page-title">blog</h1>     <div id="content">      </div> </div> 

try this:

#center-page {    position: relative;    background: green;    height: 700px;  }    #content {    position: absolute;    background: orange;    top: 40px;    bottom: 40px;    left: 0;    right: 0;  }
<div id="center-page">      <p id="center-page-title">blog</h1>      <div id="content">        </div>  </div>


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -