CSS - Flexible Website Height
Hi Guys,
I have been recently playing with some HTML/CSS and I cannot figure out a way to make my website to be flexible. I have attached a link to the screenshot to show what happens when I reach out of height. I am using min-height but I doesn't seem to responde. http://screencast.com/t/NNx4fxkFAc I will also upload my CSS and HTML code. I tried to keep it clear and easy to read. I really appreciate any help as I have been trying to fix it whole day, getting sort of desperate. Code: /*---------- Header Start ---------- */ #header { background:url(images/topbar_slice.png) repeat-x; height: 268px; } #logo { background:url(images/logo.png) no-repeat; position: absolute; padding-bottom: 30px; top: 7%; left: 3%; width:320px; height:90px; } #logo h1, #logo small { display:block; text-indent:-9999px; } ul#menu { margin:0px; padding:0px; position:relative; left:0px; top: 10px; } ul#menu li { display:inline; margin-left:50px; margin-bottom: 10px; } ul#menu li a { text-decoration:none; color:#ffffff; font-family:Helvetica, Verdana, Arial, sans-serif; font-size:10px; font-weight:bold; text-transform:uppercase; } ul#menu li a.active, ul#menu li a:hover { color:#D8D8D8 ; } #search { background: url(images/search_field.png) top no-repeat; width:178px; height: 30px; position: absolute; right: 5%; top: 1%; } #search_button { background-image: url(images/search_icon.png); background-repeat: no-repeat; width:20px; height: 20px; position: absolute; right: 10%; top: 6px; } /*--------- Header End -----------*/ /*--------- Body Start ---------- */ body { font-family:Helvetica, Arial, sans-serif; color:#7f7d78; font-size:16px; line-height:23px; } .block_inside { display:block; border:10px solid #ffffff; background: #ffffff url(images/backgroud_slice.jpg) repeat-x; padding:30px; overflow:auto; } #main { background:#c4c0be; } #main .container { background:url(images/background_slice.png) repeat-y; min-height: 700px; position: relative; margin: -0.8% 15% 0% 15%; border:1px solid #a3a09e; } .text_block { float: left; padding-right: 40%; margin-left: 40px; width: 230 px; height: 400px; text-align: justify; font-family: Helvetica, sans-serif, Arial; } h2 { margin:60px 0px 10px 0px; line-height:23px; font-size:36px; font-family:Helvetica, Arial, Sans-serif; color:#000000; } small { color:#595856; font-weight:bold; font-size:11px; display:block; margin-bottom:15px; } a { color:#007de2; text-decoration:none; } a { color:#007de2; text-decoration:none; } a:hover { text-decoration:underline; } p { margin: 0px 0px 15px 0px; } a.button { background:#32312f url(images/button_bg.jpg) repeat-x; padding:5px 10px 5px 10px; color: #ffffff; text-decoration: none; border:1px solid #32312f; text-transform:uppercase; font-size:9px; line-height:25px; } a.button:hover { background:#007de2 url(images/button_bg_o.jpg) repeat-x; border-color:#007de2; } /*--------- Body End ------------ */ /*--------- Sidebar Start -------- */ #sidebar { background-image: url(images/sidebar_slice.png); background-repeat: repeat-y; position: absolute; width: 285px; margin: -18.3% 0 50% 0; height: 80%; right: 30px; } #sponsor { background: url(images/edit.png) no-repeat; width: 200px; height: 200px; position: absolute; top: 30px; left: 10px; } #sidebar_text { color:#595856; font-weight:bold; font-size:11px; display:block; margin-bottom:15px; margin-left: 40 px; } /*--------- Sidebar End ------- */ Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Almost Student</title> <link href="style.css" rel="stylesheet" type="text/css" /> <link rel="shortcut icon" href="images/favicon.ico" /> </head> <body> <div id="main"> <!------------MAIN------------> <div class="container"> <!------------Header----------------------------> <div id="header"> <ul id="menu"> <li><a href="">Home</a></li> <li><a href="">Articles</a></li> <li><a href="">About Us</a></li> <li><a href="">Contact</a></li> </ul> <div id="search"> <div id="search_button"> </div><!--search button end--> </div> <!--search end--> <div id="logo"> <h1>Almost Student</h1> </div> <!--logo end--> </div> <!--header end--> <!------------Header End-----------------------------> <!------------Content-----------------------------> <div id="post_block"> <span> <div class="text_block"> <!--<img src="images/sample_mini_portfolio.jpg" class="thumbnail" alt="PSDTUTS" /> --> <h2>Post</h2> <small>test</small> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> <br /> <a href="a" class="button">Continue reading...</a> <!--<img src="images/sample_mini_portfolio.jpg" class="thumbnail" alt="PSDTUTS" /> --> <h2>Post</h2> <small>test</small> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> <br /> <a href="a" class="button">Continue reading...</a> </div> </span> </div> <!------------Content End-----------------------------> <!------------SIDEBAR---------------------------------> <div id="sidebar"> <div id="sponsor"> </div><!--sponsor end--> </div><!--sidebar end--> <!------------SIDEBAR END--------------------------------> </div> <!--container end--> </div> <!--main end--> <!------------MAIN END------------> <div id="footer"> <div class="container"> All rights reserved. Almoststudent.com </div> <!-- container--> </div> <!-- footer --> </body> </html> Similar TutorialsI'm trying to do something that probably isn't as difficult as it's becoming for me. I want to have a 100% height page, which I've managed okay with so far. I want the header and menu to be a fixed height, and a footer of fixed height too, with the middle section being what expands to fit the whole design. This middle section, however, is a div containing an image that needs to get its height somehow. I've reverted back to my old fixed code, which loaded a stylesheet depending on the users screen resolution, but it's too limited and I'd like to know how to go about incorporating the 100% height idea. http://www.ryanbuckley.ca/BRIT/drawings.php Hi, I have hit the "wall" in my knowledge of CSS while trying to implement a "flex-width-equal-height-sidebar-layout" style of layout as a skin/theme for a message board system and need some help. My trouble occurs when a direct link to the post is used (instead of following the menu navigation system) where the top menu information/links area (the area between the banner and the post) is chopped off... The relevant portion of the CSS seems to be the .col_wrap {margin-top: 10px; border: 0; overflow: hidden; float: left; width: 100%; position: relative; z-index: 10; clear: both;} portion of my CSS because if I take out the overflow:hidden declaration then the menu portion of the skin/theme/layout shows correctly but the sidebar the shows the part which should be hidden at the bottom and the footer completely vanishes from view! My apologies but this is the best I can do without having the ability to post pics or urls which could better explain what is wrong and frankly speaking I don't know how anyone here can help given my inability to show the problem but hopefully someone knows or has run into this problem before or can offer some resources that may be of assistance.... In my css I have the following to set up the height and width of the page to 100%: Code: html, body { font-family: verdana, arial, sans-serif; color: #000000; background-color: #E1E1E1; margin: 0; width: 100%; height: 100%; text-align: center; } For my website I have the following layout: Code: <body> <div id="container"> <div id="header"></div> <div id="menu"></div> <div id="main"></div> <div id="footer"></div> </div> </body> How do I get the <div id="main"></div> to fill in the remainder of the window height, without setting its height to 100% and them causing scroll bars and throwing the footer off the page. Okay, so I want to get an image (left) and a div container (right) positioned on the same line. The image is 225x225, and I want 15px of space between the image and div container; the div container should also fill in the rest of the width on that page. HTML = <img id="logo" src="logo.gif" width="225" height="225"><!- insert 15px spacing --><div id="navbox"><!-- 100% width? --></div> and, CSS = ? Thanks! Hi all, I am trying to automate everything on my test website and I have one more angle to cover. In effect, I want to adjust the line-height property (which I can do) based on the number of files within a specific folder (PHP and already done). The more files in the folder, the lower the line-height value must be. This is to ensure if I copy additional files into the folder, then the navigation menu (which is PHP reading files in this particular folder) will alter the CSS line-height property accordingly to ensure it can never exceed a certain height. Sounds wierd? go to www.re3.org.uk (next to the RE3 image, I have a list of hyperlinks which are obtained from files within the folder) My problem, when adjusting the CSS property (which is set as cm in *.css file) in javascript, it doesn't correspond correctly, the line-height property in javascript doesn't appear to be work in cm but some other measurement. Does anyone know how to change what unit of measurement Javascript works in? Or does anyone know what unit of measurement javascript uses when adjusting line-height / line-width values? I want to create a mini-algorithm that works out the appropriate line-height based on the image height (got that already) and the number of files in the folder (got that too) so the menu automatically adjusts to fit. Whew! I've never done much CSS work, but I know this has to be an easy fix. Each DIV appears to be 10px higher when viewed in IE. I want them to be 8px high and they end up being 18px high. In Firefox, Netscape, and Opera it works fine. Anyone mind correcting this imbarrassing little problem? Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" > <head> <title>IE 10px Padding Problem</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> body { margin:0px; } #container { position:relative; margin:auto; width:730px; } #header { height:110px; } .textualtop { border:1px solid #000000; height:8px; } .textualbottom { border:1px solid #000000; height:8px; } </style> </head> <body> <div id="container"> <div id="header"></div> <div class="textualtop"></div> <div class="textualbottom"></div> <div class="textualtop"></div> <div class="textualbottom"></div> <p>Notice how in IE6 each DIV is 10px higher then in FF. Why is it doing this?</p> </div> </body> </html> Hello Just recently I had an idea for a page I wanted to make, the design is basically a 3-column layout with no traditional header or footer, the height of all three columns should run the length of the window/page height the left and rightmost column would have a fixed width or a width in em, the center column width should fill the space in between. If the content is short all columns should extend to the height of the page window, but if the content in any of the columns is longer than the window height they should all extend to reach the bottom of the page and accommodate the content length In my first attempt things didn't go so well, results varied wildly across browsers so I decided to start from scratch bit by bit Bellow is the point at which I reach consistent but undesired behaviour, I have validated and tested the code in Firefox 3/Pale Moon, Internet Explorer 8, Chromium 9, and Opera 11 I would like the end result to work in the above browsers as well as IE7 if possible I should point out now that im not interested in using faux-columns, the layout should not require images, I also wish to have absolute-positioned elements in the columns some time later Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Three Columns</title> <style type="text/css"> *, html, body { margin: 0; padding: 0; font-size: 100%; } html, body { width: 100%; height: 100%; } #maincontainer { position: relative; height: 100%; background: #eee; } #left { position: absolute; top: 0px; left: 0px; width: 200px; background: #fbb; height: 100%; } #mid { position: relative; margin: 0 200px 0 200px; background: #efe; height: 100%; } #right { position: absolute; top: 0px; right: 0px; width: 200px; background: #bbf; height: 100%; } </style> </head> <body> <div id="maincontainer"> <div id="left"> left start<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left end<br /> </div> <div id="mid"> mid start<br /> mid<br /> mid<br /> mid<br /> mid<br /> mid<br /> mid end<br /> </div> <div id="right"> right start<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right end<br /> </div> </div> </body> </html> In the above example it works as long as the content within the columns is shorter than the window height, but if you re-size the window so that the text in the right or left column goes beyond the page, and then scroll to the bottom, the columns do not extend to the bottom of the page so there is a large gap where the content overflows beyond the column What I would like to do from this point is make the columns extend to the bottom of the page when this happens, but I'm not sure how best to proceed I also have a version of the above code which uses floated left and right columns instead of absolute positioned ones, would it be better to work from that? or does it not really matter Thanks in advance Hello everybody! I have been having a big problem with my webpage for a long time now and hope I can find an answer to my problem with your help. I want a div that contains the content of my pages (which varies in length depending on the individual page) to stretch the length of my page, but it only stretches the length of the window. Here's the HTML and CSS: HTML (I only included the very basic structure): <html> <body> <div class="container"> <div id="content"> <div id="..."></div> <div id="..."></div> <div id="..."></div> <div id="..."></div> </div> </div> </body> </html>` CSS: html, body { height: 100%; font-family: Arial; font-size: 10px; color: #000000; background: #FFF url(../../images/body.png) no-repeat center 40px; margin: 0; position: relative;} .container { height: 100%; width: 960px; margin-right: auto; margin-left: auto; position: relative;} #content { width: 939px; min-height: 100%; position: relative; top: 210px; left: 6px; box-shadow: 0px 0px 8px #666; -moz-box-shadow: 0px 0px 8px #666; -webkit-box-shadow: 0px 0px 8px #666; background-color: #FFF;} I tried to set the content div to overflow: auto, but that includes a scroll bar for the content div that I do not want. It does, however, create the desired effect of the shadow and background of the #content div all the way to the end of the page. Am I missing anything? I thought min-height would work, but it doesn't! It only stretches the content div to page height and everything else is overflow, but without the content div's background color and shadow. Does anybody maybe see where the problem lies? Thank you so much in advance for your help. It seem that everytime I added the image tag, the div'x area get bigger in IE but not in Mozilla/Firefox browser. So, I thought by added the "margin-bottom:-360px;" to the div would fix it but it had an opposite effect. Meaning it worked in IE but Mozilla show a vertical scrollbar. So, does anyone know how can I make the <img> overlap one another without being stacked on one after another in height for IE if I take out the "margin-bottom: -360px;"? Thanks... Code: div.divBox1 { width: 286px; height: 359px; float: left; } div.divClearFloat { clear: both; height: 0px; /* For IE Stupidity (it added some spaces after clearing the float) */ font-size: 1pt; /* For IE Stupidity (minimum height only work with current font-size somewhere) */ } div.divDottedLineAdvertisementSeperator1 { width: 575px; height: 3px; background-color: #ff0000; font-size: 1pt; /* For IE Stupidity (minimum height only work with current font-size somewhere) */ } Code: <div class="divBox1"> <div style="margin-bottom:-360px;"> <img src="images/doctor.jpg" style="position:relative;top:0px;left:0px;z-index:2;"> <img src="images/we_help.jpg" style="position:relative;top:-360px;left:0px;z-index:1;"> </div> </div> <div class="divClearFloat"></div> <div class="divDottedLineAdvertisementSeperator1"></div> If you look at the bottom of the page at www.res-technologies_DOT_com/index.php?jos_change_template=restech2 in both IE and FF, you will see that it looks fine in IE, but in FF the page length is extended by exactly the height of the header image at the top of the page. Trying to figure out what's causing this is driving me nuts! Can anyone help? thx dh I am having a problem trying to get one column match the height of another. Within a large DIV box, I created two columns separated by about 20 px. I floated one to the left, then pushed one over to the right. Both boxes will expand depending on the amount of content, but I would like them to match the same height. The boxes will be used throughout the entire website, so it would not make sense to create a background image to try and trick it into being the same height.. or actually specifying the height. Is there any way to tell the left box to be the same height as the right box?? I tried to link to my site but it won't let a new member link to a website. My web page has a display bug in IE 5+ on Windows. Specifically, I have a DIV within which I wish to place two images. The two images are the same height and width, and I want to layer them (the top one is a PNG with transparency, but I have already solved that problem, this is a positioning problem) exactly on top of each other. I have done this by positioning them relatively within the DIV. The first image is top:0;left:0 and the second is top:-150;left:0 (the images are 150 px tall). They layer fine, but the DIV is twice the height (as if the second image were still following the first, making he DIV 300 px tall). I have tried many things and am stumped. Here is the site: URL Here is the relevant CSS: Code: #bannerPhoto { border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #000000; height: 150px; width: 750px; } #bannerPic { position: relative; z-index: 1; left: 0px; top: 0px; } #bannerText { position: relative; z-index: 2; left: 0px; top: -150px; } And the HTML: Code: <div id="bannerPhoto"> <div id="bannerPic"><img src="../images/bannerPhotos/image.jpg" height="150" width="750" /></div> <div id="bannerText"><img src="../images/text-cover.png" height="150" width="750" /></div> </div> Anyone? Thanks, Denver. i came across a solution for this a while ago and can't repeat the result i have 3 columns, div format with a left left right float. 1 2 3 #2 contains content that varies with the page, #1 and #3 contain background elements. i need 1 and 3 to extend the full height of 2, even tho the actual content is much less. thanks for the help! Hi Guys, Consider the following box: PHP Code: <div style=border: 1mm black Solid; width: 148mm; height: 98mm;'> </div> 148mm + 1mm + 1mm = width of 150mm 98mm + 1mm + 1mm = width of 100mm Now why does neither firefox or ie manage to get it? Firefox is about 2mm out and ie is about 3mm out? Any ideas or is it some quirk? Charlie Hey folks, k...this site is doing what it is supposed to in IE, but I think i'm missing something or messed something up, cause in FF, the white background stops in the top of the viewport. Here's the css. They both validate. Any help'd be appreciated. Thanks! I am using an image for my header. It is contained inside a header div defined as such: Quote: div#header { margin: 0px; /* padding-bottom: 10px; */ background-color: #000000; border-bottom: 1px solid white; } So whats with the black line below the image? Ive also specified the image to have a class defined as such: Quote: .img { border: 0px none; } http://www.nevertap.com/event.php This is a strange quirk, ive tried adjusting the height element but with no luck. I was under the impression height reacted like an auto property, only expanding to include the objects inside them. Thanks for taking the time to read my question. Shouldn't Height: 100%; make a container the height of the browser window? Thanks, Brad i tryed create a little spacer off 1px high but when iview what ive done the height looks around 20px? div#space {width:248px;height:1px;background-color:#f1d4f0;} please help :] Hi all, I'm in the middle of creating a web app and i'm trying to get 2 columns to fill the height of the screen, i can do this if i know the height of the top div (see diagram below), but i'd prefer to keep that flexible because the content's of it will change. i've tried using javascript to get the remaining height, but again this'll only work if i know the height of the top div (i'd get the column height by subtracting the top div height from the browser's screen height) ... plus i'd prefer not to rely on javascript to do this thought i'd ask if anyone else has been suffering from this problem and has managed to find a fix? thanks for any help Hi everyone. Does anyone have any ideas about this and this? If you make the text smaller (doesn't work in IE) OR have a screen resolution above 1024x768 you will notice that under the text the white doesn't continue but the blue does, any idea how to fix this? I have tried setting min-height: 100% (height in IE) that works, but then there is a scroll bar when not needed, the extra space appears to be the same amount of the header bar. NOTE: I am NOT using tables. Thanks for any help. JamesRP |