CSS - Background For 100% Height Container Div
Hi
I have searched on this subject, and found the Faux Column articles, but I have failed to make use of these. The following page shows the problem LINK And CSS The text in the container div leads off the bottom of the page. The CSS is a bit of a mess at the moment because I have been messing with it trying to get this to work. I need the background of the container div to extend to the bottom of the content div. I have set min-height and heights for the body and html tags, and then for the container, as I know that the height is only taken into account if the parent has a height too. This does not work. Any suggestions? Thanks Jake Similar TutorialsHey guys, I have a web layout with 1 centre column with a height of 100% (i.e. it fills the whole window from top to bottom). I have achieved this using height: 100% and its worked so far but I've just hit a problem. When the content is less than the height of the browser window it is fine - the white extends to the bottom perfectly in both FF and IE. However, if the content extends over the height of the window, the white background stops. So the CSS is making the column the height of the window without taking into consideration the content that is inside it so that when you scroll down, the background dissappears. Any help would be appreciated. The page that works fine: http://www.dgwd.co.uk/1476/site/aircadets/index.php The page that doesnt: http://www.dgwd.co.uk/1476/site/aircadets/uniform.php Thanks a lot guys. Dan Hi, i seem to be having a problem displaying my container as 100%. I have a centred column with a grey background with the following as my html and my css: Code: <html> <head> <link rel="stylesheet" href="default.css" type="text/css" /> </head> <body> <div id="container"><!--BEGIN CONTAINER--> <div id="logo"></div> <div id="motto"> <div id="telno"></div> <div id="quote"></div> </div> <div id="navigation"> </div> <div id="search"><!--BEGIN SEARCH--> </div> <div id="banner_1"></div> <div class="box"></div> <div class="box"></div> <div class="box"></div> <div class="empty"></div> <div class="box2"></div> <div id="contenthome"></div> <div id="sectiontwo"></div> <div id="sectionthree"></div><!--END SECTION THREE--> <div id="footer"></div><!--END FOOTER--> </div><!--END CONTAINER--> </body> </html> CSS Code: *{ padding:0; margin:0; } body { height: 100%; font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #797979; margin: 0; padding: 0; background-color:#dfdede; } div { border: 1px solid #000; } a { font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #66308f; text-decoration:none; } #container { height: 100%; width: 927px; margin: auto; padding-left: 10px; padding-right: 10px; background-color: #ffffff; min-height: 100%; /* for mozilla */ } #logo { background-image:url(../images/logo.jpg); background-repeat:no-repeat; height: 164px; width: 374px; float: left; margin-top: 0px; margin-left: 0px; } #motto { height: 164px; width: 549px; float: right; margin-top: 0px; } #telno { height: 58px; width: 549px; float: right; margin-top: 24px; text-align:right; } #quote { height: 80px; width: 549px; float: right; margin-top: 0px; font-size: 25px; color:#2a4b59; text-align:right; } /* top menu navigation */ #navigation { height: 35px; width: 670px; float: left; margin-top: 0px; } /* search box */ #search { height: 35px;width: 253px; float: left; margin-top: 0px; background-color:#66308f; text-align:center; vertical-align:middle; } .button {margin:0px 0 -3px 5px;} .inputbox { width: 13em; margin:2px 0 0px 0px; color: #878484; text-align:left; } /* search box end */ .box{ height:52px; width:205px; float: right; margin-top: 0px; margin-right: 0px; margin-bottom: 4px; margin-left:0px; } .empty { height: 94px; width: 205px; float:right; } .box2{ height:141px; width:205px; float: right; margin-top: 0px; margin-right: 0px; margin-bottom: 4px; margin-left:0px; } #contenthome { height: 50px; width: 927px; float: left; margin-top: 5px; margin-left: 0px; } #sectiontwo { height: 50px; width: 927px; float: left; margin-top: 0px; margin-bottom: 10px; } #sectionthree { height: 50px; width: 927px; float:left; margin-top: 0px; margin-bottom: 15px; } #footer { background-color:#b3d800; height: 56px; width: 927px; float: left; margin-top:0px; } #banner_1 { height: 413px; width: 701px; float: left; margin-top: 0px; margin-left: 0px; border-right-color: #FFFFFF; border-right-style: solid; border-right-width: 2px; } but for some reason i cant seem to get the container to fill the complete height of the page and i cant seem to locate what error i have made. If somebody could please help, as i would like this to work in all browsers. Thanks in advance. Hi guys, I have a small problem which is driving me crazy. I have a main container with two containers inside named left and right. I want a border on the main container, but i do not know the height of the main container as this will depend on the content in 'left' and 'right'. So what should I set the height of the main container to? I've tried 100% but this does not work and if I omit the geight property the main container does not show up. Any ideas? Thanks in advance, Rob. Hi, I have 3 div boxes in a container, they sit side by side (i.e. 3 in a row) with different amounts of text in each div. The dilemma is that I need all the div's to be the same height as the tallest div. can someone tell me how to do this? thanks Thanks for taking the time to read my question. I have posted what I'm working on at http://www.scopicdesigns.com/ZoneAll/NewIndex.htm I have put a yellow background on the main nav container to illustrate my problem. There seems to be extra height to the .NavContainer in IE6, but it is not there in IE7 or FF. I've tried adjusting all my margins and paddings, but nothing seems to work. I also tried increasing the width of the .NavContainer, thinking that there was some sort of overflow from the last button or something, but that didn't work either. How do I get rid of this? Thanks, Brad Hi, Hopefully someone here will have experienced this issue before..what I have done is create a div to contain all of the layout elements I want on my page. I started inserting a few of these and I noticed the container div doesn't stretch unless I specify a height which I wanted to avoid should I create an pages that have a limited amount of content and don't fill the page. Here is what I have so far here and this is what I want to achieve here As you can see I have specified a height value in the sceond example, is there an alternative way of doing this? Also is the best way to position the footer at the bottom of the container like so Code: position:absolute; bottom:0px; Thanks for any help guys. p.s. Here are my stylesheets so far Stylesheet 1 Code: /* CSS Document */ body { background:#CCC url(images/Bg.gif) repeat top left; text-align:center; } #container { background:#FFF; width:715px; border:1px solid #000; } #header { background:#000 url(images/Header1.jpg) repeat top left; width:703px; height:172px; border-left:1px solid #000; border-right:1px solid #000; border-bottom:1px solid #000; border-top:0px none #000; position:absolute; left: 5px; top: 5px; } #logo { background:#000 url(images/Contemporary-Classics.gif) repeat top left; width:383px; height:52px; position:absolute; left: 15px; top: 15px; } #footer { width:715px; background-color:#A18A39; padding:0px; margin:0px; } Stylesheet 2 Code: /* CSS Document */ body { background:#CCC url(images/Bg.gif) repeat top left; text-align:center; } #container { background:#FFF; width:715px; border:1px solid #000; position:relative; height:500px; } #header { background:#000 url(images/Header1.jpg) repeat top left; width:703px; height:172px; border-left:1px solid #000; border-right:1px solid #000; border-bottom:1px solid #000; border-top:0px none #000; position:absolute; left: 5px; top: 5px; } #logo { background:#000 url(images/Contemporary-Classics.gif) repeat top left; width:383px; height:52px; position:absolute; left: 15px; top: 15px; } #footer { width:715px; background-color:#A18A39; padding:0px; margin:0px; position:absolute; bottom:0px; } Hi, I have two images which are on top of each other, and the one on top is hidden. I use JS to change the source of the top to a new image, then fade the top image visible, then change the source of the bottom to be the same as the top, then make the top hidden (and so on and so on). To position the images on top of each other, I am using position: absolute. This works well when the DIV container has a defined height, however, when not the DIV collapses upon itself and the images are not displayed. Any suggestions how I might overcome this? Thanks Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test Heights</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <style type="text/css"> .mod_rotator { position: relative; overflow:hidden; height: 100px; } .mod_rotate_image {position: absolute;} img.mod_rotate_image.front {display: none;} </style> </head> <body> <div class="mod_rotator"> <img class="mod_rotate_image back" src="images/rotator/corporateimage1.jpg" /> <img class="mod_rotate_image front" src="images/rotator/corporateimage1.jpg" /> </div> </body> </html> Well I'm running into just a few difficulties trying to enclose a object inside of another container. The problem is that the container does not repeat the background when I lengthen the boxes within it. Can someone with a excellent CSS eye take a look at this and let me know what I'm doing wrong. I've played with overflow:auto; but the problem is that I need to set the width of the container at 990px, and it doesn't seem to work if I statically set the width. http://www.obelix.ca/templates/index.html I am trying to set a height of a container div, and have the inner div spill out of the container without changing the height of the container div: Code: <style media="screen" type="text/css"> .inner{ width: 80px; height: 80px; background-color: #0000FF; } .outer { width: 120px; height: 20px; background-color: #FFFF00; overflow:visible; } </style> IE 6 is giving me trouble. It insists on making the container div the same height as the inner div. Anything I can do to tell IE6 to not change the height of the container? I have read and read through the CSS2 spec and I am unable to figure out if this is possible. Hopefully I can describe it well enough for somebody to help out. Okay, what I want to accomplish seems simple. I want a div, lets call this one "container", with a calculated height/width relative to the document (in terms of percentage). Inside this div will be another div, lets call it "header", whos width will span the length of the containing div (100%) and height is fixed, lets say 30px. Now here comes the tricky part... a third div, lets call it "content" should sit right underneath "header" and its width will also be 100% of the containing div, but the height should fill the remainder of the containing div. I can't seem to get the "content" div to fill the remainder of "container" and scroll when needed. If I specify a calculated height, the offset of the "header" div is not taken into account so "content" div does not fit properly. Thanks a ton if you can help me out. Please let me know if this doesn't make sense. Here's the template I'm working on: http://dhost.info/justusvizslas/template.php Here's my problem: I'm trying to create a centered, two-column layout with a header and a footer, sort of like the tutorial he http://nemesis1.f2o.org/aarchive?id=7 I've got everything working correctly and it looks fine in IE. However, in FireFox, the container div doesn't automatically adjust its height to be the same as the height of the divs inside. Instead, I have to set the height at a certain number of pixils to even get the container div to show up. When I do that, in IE the container div defaults to the same height as the larger of the two inner divs, but in FireFox the container div just stays at whatever pixil height I specified. That becomes problematic because I don't plan on having all my pagecontent divs with the same height. Any insight will be greatly appreciated. I've been looking at this for hours and haven't gotten it to work like it should. Here's the relevant code too: CSS Code: #container { width:792px; height:50px; margin: auto auto; color:#000000; background-color:#FFFFFF; background-image:url(design/menuimage.gif); background-repeat:repeat-y; } #navigation { width:125px; height:auto; padding:0px; float:left; margin-top:auto; vertical-align:top } #pagecontent { width:667px; height:auto; padding:0px; float:left; margin-top:auto; color:#000000; background-color:#FFFFFF; text-align:center } PHP Code: <div id="container"> <div id="navigation"><?php include "nav.php"; ?></div> <div id="pagecontent"> <br />Some more content here<br /> </div> </div> Again, thank you in advance for any help with this. If you're stumped and think it should work as-is, go ahead and go to the actual template I'm working on (first http link in this post) and look at it in IE and in FireFox to note the difference. I may be trying to square the circle here. I have a container that is not the full length of the page [padding top and bottom]. Within the container, I have 2 main content elements: 1. a nested div forms a strip down the left edge, holding a decorative pattern. [note: it doesn't currently extend down the entire left edge ~ other items are above it ~ but I can include those in the strip and make it 100% if the idea is workable]. 2. the main content div is beside it. The container automatically adjusts to the height of the entire content in both divs. I'd like for the 'decorative' div to automatically adjust to 100% height of the container instead [ie. match the height of the content to the right of it - automatically]. Is this possible? Kravvitz....I know How do you make a container div aware of the height of floated divs nested inside? I have 2 floated divs, which are contained within a container div. The container has a background image that I need to tile vertically. In FF the image does not tile unless I specifiy a height for the container other than auto. I don't want to set it to 100% because when I do, the container div extends much further than I intend it to. Here is the link to the site with the problem. CSS Code: /* CSS DOCUMENT */ html, body { padding: 0px 0px 0px 0px; font: 10px Verdana, Arial, Halvetica; height: 100%; text-align: center; background: url(../images/bdy_back.jpg) #252525 no-repeat center; #container { width: 938px; margin: 0 auto; text-align: left; height: auto; opacity: .90; filter: alpha(opacity=90); background: url(../images/middle2.jpg) repeat-y right #444444; } #lcol{ float: left; width: 15%; height: auto; } #right { float: right; width: 85%; height: 100%; } } HTML Code: <div id="container"> <div class="hdr"> <div id="officer" style="display: none;"></div> </div> <div id="lcol"> </div> <div id="right"> </div> </div> <div id="footer"> </div> say you have a page with 2 main columns inside a container. the right column is a sidebar. both are supplied content dynamically. i'd like the container (inclusive) to be the height of the content column (as determined by its children), and the sidebar should scroll (vertically) its content based on that size. there's a (non-functional) example attached. if you run it you can see the container takes the height of the sidebar - it (the bordered container) should end at the bottom of the content div, and the sidebar should scroll. it's laid out using floating divs, but tables would be fine; javascript is not (per client). any ideas would be welcome. tyia. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> .container { border : 1px solid #F90; /* just to show container height */ } .content { float : left; width : 400px; height : 100%; } .sidebar { float : left; width : 400px; height : 100%; } .scroller { overflow : scroll; height : 100%; } </style> </head> <body> <div class="container"> <div class="content"> <p>Random content</p><p>Random content</p><p>Random content</p><p>Random content</p> <p>Random content</p><p>Random content</p><p>Random content</p><p>Random content</p> <p>Random content</p><p>Random content</p><p>Random content</p><p>Random content</p> </div> <div class="sidebar"> <div>Sidebar</div> <div class="scroller"> <p>This content should scroll.</p><p>This content should scroll.</p><p>This content should scroll.</p> <p>This content should scroll.</p><p>This content should scroll.</p><p>This content should scroll.</p> <p>This content should scroll.</p><p>This content should scroll.</p><p>This content should scroll.</p> <p>This content should scroll.</p><p>This content should scroll.</p><p>This content should scroll.</p> <p>This content should scroll.</p><p>This content should scroll.</p><p>This content should scroll.</p> <p>This content should scroll.</p><p>This content should scroll.</p><p>This content should scroll.</p> <p>This content should scroll.</p><p>This content should scroll.</p><p>This content should scroll.</p> <p>This content should scroll.</p><p>This content should scroll.</p><p>This content should scroll.</p> <p>This content should scroll.</p><p>This content should scroll.</p><p>This content should scroll.</p> </div> </div> <div style="clear:both"></div> </div> </body> </html> Hi! Is it possible to align vertically block elements in a fixed-height (unknown) container? If not, this is a serious shortcoming of the css model of placing objects on the screen. Thanks! Hey guys, I've recently started working on my css and for some reason my background image isn't showing up in my container. Any idea why? CSS Code: Original - CSS Code /* CSS Document */ * { margin: 0; padding: 0; } body { font-size: 62.5%; background: #344149; } p, li { font: 1.2em/1.8em Tahoma, sans-serif; margin-bottom: 10px; } h1 { font: 2.0em Tahoma, sans-serif; color: white; height: 0px; } h2 { font: 1.8em Tahoma, sans-serif; color: green; margin-bottom: 10px; } ul { margin-left: 25px; } img { border: none; } #page-wrap { background: black; min-width: 780px; max-width: 1260px; margin: 10px auto; width:expression(document.body.clientWidth < 782? "780px" : document.body.clientWidth > 1262? "1260px" : "auto"); } #page-wrap #inside { margin: 10px 10px 0px 10px 10px; padding-top: 10px; padding-bottom: 10px; } #main-content { background: transparent url(/Images/Background_Content.jpg) no-repeat top right; padding-left: 180px; padding-right: 180px; padding-top: 20px; } #header { background: #000000; text-align: center; } #left-sidebar { background: transparent url(/Images/Background_Content.jpg) no-repeat top right; width: 150px; float: left; padding-left: 15px; padding-top: 20px; } #right-sidebar { background: transparent url(/Images/Background_Content.jpg) no-repeat top right; width: 150px; float: right; padding-right: 15px; padding-top: 20px; } #footer { background: #267f23; text-align: center; padding-top: 20px; padding-bottom: 20px; color: white; } /* CSS Document */ It's the Background_Content.jpg that isn't loading for some reason. It resides in the Image folder located in the same directory as the html file. Oh and the reason I had it included so much was to test to see if it was just the main-content that wouldn't load it. The main content should include the left-sidebar and right-sidebar right? Please help! I've been working on converting to css for table-like layout. I have the three column variety with a header. Around all 4 is a container to keep things ship shape. My issue is that even though I've specified a background colour for the container it doesn't seem to override the body color making the column lengths uneven. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>mrhodges.net: A web site for Mr. Hodges classes</title> <style type="text/css" > body { background-color: #014e82; text-align: center; font-family: Georgia, serif; } #container { width: 90%; margin: 10px auto; background-color: #ffffff; text-align: left; } #banner { background-color: #014e82; padding: 1px; } #banner p.title { font-size: 2.5em; color: #ffffff; background-color: #014e82; text-align: center; margin: 0; padding: 0 0 5px 0; } #banner ul { list-style-type: none; text-align: center; padding: 0 0 10px 0; margin: 0; font-family: Verdana, arial, sans-serif; font-size: 10pt; color: #ffffff; } #banner ul li { display: inline; } #banner ul li a { text-decoration: none; padding: 0; } #banner a:link { color: #ffffff; padding: 0; } #banner a:visited { color: #ffffff; padding: 0; } #banner a:hover { color: #ffffff; text-decoration: underline; padding: 0; } #banner a:active { color: #54b818; text-decoration: underline; padding: 0; } #leftnav { float: left; width: 160px; margin: 0px; padding: 3px 5px 5px 5px; background-color: #fff; } #leftnav ul { margin: 0; padding: 0; list-style-type: none; } #leftnav a { display: block; color: #049; background-color: #fff; text-decoration: none; padding: 0 0 0 5px; } #leftnav a:hover { background-color: #ddd; color: #049; } #rightnav { float: right; width: 160px; margin: 0px; padding: 3px 5px 5px 5px; background-color: #fff; } #middle { margin-left: 160px; margin-right: 160px; padding: 10px; } </style> </head> <body> <div id="container"> <div id="banner"> <p class="title">mrhodges.net</p> <ul> <li><a href="http://www.cbc.ca/news/">CBC News</a> |</li> <li><a href="http://dictionary.reference.com/">Dictionary</a> |</li> <li><a href="http://www.fmcsd.ab.ca">FMCSD</a> |</li> <li><a href="http://www.google.ca">Google</a> |</li> <li><a href="http://www.mymcmurray.com">mymcmurray</a> |</li> <li><a href="http://www.theweathernetwork.com/weather/cities/can/Pages/CAAB0124.htm">Weather</a> |</li> <li><a href="http://en.wikipedia.org/wiki/Main_Page.html">Wikipedia</a></li> </ul> </div> <div id="leftnav"> <ul> <li><a href="overview.html">Course</a></li> <li><a href="overview.html">Overview</a></li> <li><a href="outline.html">Outlines</a></li> <li><a href="outline.html#modules">Modules</a></li> <li><a href="projects.html">Projects</a></li> <li><a href="rap.html">RAP Program</a></li> </ul> <br /> <ul> <li>Safety</li> <li>Consent</li> <li>.pdf form</li> </ul> <br /> <ul> <li><a href="dates.html">Dates</a></li> <li><a href="dates.html#term">Term</a></li> <li><a href="dates.html#plc">PLC Days</a></li> <li><a href="dates.html#holi">Holidays</a></li> <li><a href="dates.html#inter">Interviews</a></li> <li><a href="dates.html#mod">Module</a></li> <li><a href="dates.html#exam">Exam</a></li> </ul> <br /> <ul> <li><a href="http://www.mrhodges.blogspot.com">Daily Log</a></li> <li><a href="http://www.mrhodges.blogspot.com">Class Log</a></li> </ul> <br /> <ul> <li><a href="contact.html">Contact</a></li> <li><a href="contact.html">School</a></li> <li><a href="contact.html">Mr. Hodges</a></li> </ul> <br /> </div> <div id="rightnav"> <ul> <li>link</li> <li>link</li> <li>link</li> <li>link</li> <li>link</li> <li>link</li> <li>link</li> <li>link</li> <li>link</li> <li>link</li> <li>link</li> </ul> </div> <div id="middle"> <p>The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. </p> </div> </div> </body> </html> Hoping someone can help me out as I'm still pretty new to the whole web design thing. I'm using CSS to create a container wrapper. As you can see from the code I have a bottom, top and center image. When I was using JPEG images everything lined up correctly, however I needed to switch to PNG image files (to take advantage of transparency) and now the top and bottom sections of the wrapper are offset. Here is a live link: storrepictures.weebly.com/projects.html -Please find an image of the resulting problem he http://i.imgur.com/YnTS8.png -This is how it looks when I use JPEGs instead of PNGs: http://i.imgur.com/2WMFN.png Here is my CSS wrapper code: Code: #wrapper { background: url(containerbg.png) center repeat-y; } #wrappertop{ background: url(containertop.png) top center no-repeat; } #wrappertbtm{ background: url(containerbtm.png) bottom center no-repeat; padding-bottom: 65px; } And here is the HTML: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>{title}</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!--[if lt IE 7]> <style> #content { height:400px !important; } </style> <![endif]--> </head> <body class="wsite-theme-light"> <div id="wrappertop"> <div id="wrapper"> <div id="header"> <div id="headerleft">{logo max-height="60"}</div> <div id="navigation">{menu}</div> </div> <div id="content">{content} <div id="footer">{footer} <div id="wrappertbtm"> </div> </div> </div> </div> </div> </div> </body> </html> Look at this page - http://certified.tmhdesign.com/about.asp I have a div called container, then in that div one called header, content_right, content_left, and footer. What is frustrating me is that I have to hard code a min-height for the left and right colums and if you scroll down you'll see where the background color of the body appears below the right column which I want to be white. When I specify the color of the container that does not fix the issue. Any help would be appreciated. Thanks. |