html - "Stretching" the background container to hold all of it contents -


i have following problem.

i have done following:

in css file, have declared both body , div tag enclosed in body, height: 100%; (the div tag technically <asp:panel> tag, get's rendered div tag.

this works fine, , div container scale fill browser top bottom, , not give scrollbar, intended to.

however, on 1 of sub-pages, page_load method add controls panel/div, , controls enough fill more height of screen, , therefore vertical scrollbar given should. however, when start scrolling, part of content below height of screen not background. background still constrained max height of screen if it's contents exceeding height.

i assume height:100% causes problem here, have not found replacement works should in case. tried height:auto; causing background removed in it's entirety.

the question might basic, not web programming these days, please bear me :)

edit

as additional information, should mention content added inside div inside original div if matters.

edit 2

some of relevant html , css:

<html> <title></title> <body>   <form>     <div class="maincontainer">       <h1>my header</h1>       <div class="mainmenu">         ...       </div>       <div id="pagecontents_blogpostpanel" class="contentcontainer">         ...(these contents extend beyond bottom of page)!!       </div>     </div>   </form> </body> </html> 

and here extracted css parts:

* {     margin: 0;     padding: 0; }  html, body {     background-color: #6cc66c; height: 100%; }   form {     background: #6cc66c url(  'images/shadowbackground.jpg' ) repeat-y top center;     height: 100%; }  body h1 {     display:none; }  .divheader {     font-family: arial, sans-serif;     font-size: 22px;     color: #d04444;     padding-top:20px;     padding-bottom:10px; }  p {     font-family: arial, sans-serif;     font-size: 16px; }  {     font-family: arial, sans-serif;     font-size: 16px;     text-decoration: none; }     .maincontainer {     background: #6cc66c url( 'images/mainbackground.jpg' ) no-repeat top center;     width: 1040px;     height: 100%;     margin: auto;     background-color: #f7f7f7; }  div.mainmenu {     position:relative;     float: right;     margin-right: 38px;     margin-top: 103px;     width: 495px; }  .mainmenu a:link img, a:visited img { border: 0px; }  .contentcontainer {     float: left;     margin-top:90px;     margin-left:80px;     width:550px; } 

i have solution , it's rather simple. :)

.maincontainer {     ...     display: table; } 

(remove height: 100% elsewhere too, it's redundant.)

some spec info on that: http://www.w3.org/tr/css2/tables.html here: w3schools.com/css/pr_class_display.asp (apparently can post 2 links new user right now)

regarding use of height: 100%, doing make elements height equal height of it's parent element - in case document window, not contents of it. spec info here: http://www.w3.org/tr/css21/syndata.html#percentage-units

regards.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -