css - Make a div scroll when content exceeds available height -
i'm trying middle div #content scroll when height of content exceeds available height (as defined innerwidth - header height - footer height).
instead, div has scrollbar doesn't scroll, , whole page has scrollbar instead.
body { margin: 0; } #header { background-color: silver; height: 100px; width: 100%; } #content { overflow: scroll; } #footer { background-color: silver; bottom: 0px; height: 100px; position: fixed; width: 100%; } <div id="header">header</div> <div id="content"> a<br>b<br>c<br>d<br>e<br>f<br>g<br>h<br>i<br>i<br>j<br>k<br>l<br>m<br>n<br>o<br>p<br>q<br>r<br>s<br>t<br>u<br>v<br>q<br>x<br>y<br>z<br> a<br>b<br>c<br>d<br>e<br>f<br>g<br>h<br>i<br>i<br>j<br>k<br>l<br>m<br>n<br>o<br>p<br>q<br>r<br>s<br>t<br>u<br>v<br>q<br>x<br>y<br>z<br> a<br>b<br>c<br>d<br>e<br>f<br>g<br>h<br>i<br>i<br>j<br>k<br>l<br>m<br>n<br>o<br>p<br>q<br>r<br>s<br>t<br>u<br>v<br>q<br>x<br>y<br>z<br> </div> <div id="footer">footer</div>
give #content fixed height, , work. right doesn't work because #content has dynamic height, , instead of scrolling when overflowing (because never overflow), expand.
see snippet below.
(i set body , html height: 100% , height of #content calc(100% - 200px) fill space not filled header or footer).
body, html { margin: 0; height: 100%; } #header { background-color: silver; height: 100px; width: 100%; } #content { overflow: scroll; height: calc(100% - 200px); } #footer { background-color: silver; bottom: 0px; height: 100px; position: fixed; width: 100%; } <div id="header">header</div> <div id="content"> a<br>b<br>c<br>d<br>e<br>f<br>g<br>h<br>i<br>i<br>j<br>k<br>l<br>m<br>n<br>o<br>p<br>q<br>r<br>s<br>t<br>u<br>v<br>q<br>x<br>y<br>z<br> a<br>b<br>c<br>d<br>e<br>f<br>g<br>h<br>i<br>i<br>j<br>k<br>l<br>m<br>n<br>o<br>p<br>q<br>r<br>s<br>t<br>u<br>v<br>q<br>x<br>y<br>z<br> a<br>b<br>c<br>d<br>e<br>f<br>g<br>h<br>i<br>i<br>j<br>k<br>l<br>m<br>n<br>o<br>p<br>q<br>r<br>s<br>t<br>u<br>v<br>q<br>x<br>y<br>z<br> </div> <div id="footer">footer</div>
Comments
Post a Comment