Forum Moderators: not2easy

Message Too Old, No Replies

Height: 100%; problems in Firefox

         

DarkFlame

6:36 am on May 31, 2009 (gmt 0)

10+ Year Member



Hint: To skip needless rubbish, start reading from 'Enough back story'

I'm new here, I registered here because i noticed a lot of helpful advice coming from these boards. But enough flattery and kissing up.

A few weeks ago I was contracted to build a website for some girls and their class project (its going to be a business with shares and sponsors and what have you,...eventually). Now being the cockey kind of guy I am, I accepted to build them a free website with only my limited knowledge of html to back me up.

I did a little research and found that CSS would be the best way to build it, considering the fact that most of them don't understand tabbed browsing, so with alot of tutoring I hope to be able to teach them how to alter the content on their page's by opening the HTML in notepad. Ofcoarse then having the actual layout in a separate file (layout.css ironically enough) would make this easier for them.

Enough back story, the site I have built them (with no help so far :D ) has one issue in FireFox. You will likely be able to see this by opening this link in FF: <snip> That darned sidebar thingy doesn't want to stay inside that black box thingy!

Here is the site: <snip>

Please help.

[edited by: swa66 at 8:12 am (utc) on May 31, 2009]
[edit reason] No personal URLs post relavant minimal code instead [/edit]

DarkFlame

8:58 am on May 31, 2009 (gmt 0)

10+ Year Member



Sorry about posting the links. In my haste for help I may of skipped over reading a few of the rules.

So here is the css.


.bound {
height: 100%;
width: 90%;
margin-left: 5%;
margin-right: 5%;
border: 2px double #000000;
background-image: url(images/header2.png);
background-repeat: no-repeat;
background-position: top right;
}


.side {
background-position: right;
background-image:url('images/sideright.png');
background-repeat:repeat-y;
padding: 2px;
height: 100%;
text-align: left;
font-family: Tahoma, Arial, sans-serif;
font-size: 14pt;
width: 15%;
float: left;
}

My problem is that this displays the .side and .bound at exactly the same height (in pixels), however I have positioned .side about 210 pixels down the page which means the bottom of it is 210 pixels below the .bound box.

I hope you guys understand, I'm not really up with the play on the terms and expressions.

DarkFlame

10:15 am on Jun 1, 2009 (gmt 0)

10+ Year Member



please...

I am working to a deadline and cant find a solution myself.

htdawg

10:18 am on Jun 1, 2009 (gmt 0)

10+ Year Member



maybe this might help [webmasterworld.com...]

swa66

12:08 pm on Jun 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



height: 100% is supposed to give an element the height of the direct parent provided that direct parent has an explicitly set height different from "auto". There is but one exception: the root element has the height of the viewport.

Setting height needs to take into account what happens if the height is going to be insufficient.

A solution to have a child fill from x pixels down into a parent element to the bottom of said parent lies within absolute positioning.
This will fail in IE6, but that can be fixed with IE7.js to teach it that top and bottom can be set at the same time.

E.g.:


<!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" lang="en">
<head>
<title>untitled</title>
<style type="text/css">
* {
margin:0;
padding:0;
}
html, body {
height: 100%;
background-color: yellow;
}
#side {
position: absolute;
top: 210px;
bottom: 0; /* set it on the bottom */
right: 0;
width: 15%;
background-color: red;
}
#wrapper {
position: relative; /* gain position */
width: 75%;
min-height: 100%;
background-color: orange;
margin: 0 auto; /* centering */
padding-right: 15%;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="side">sidebar</div>
yada yada
</div>
</body>
</html>

You'll need to add IE7.js for IE6 to have any chance of showing this properly.
You'll also need to deal with content that's too large for what's left in space in the containers.

superds

4:48 pm on Jun 1, 2009 (gmt 0)

10+ Year Member



you should calculate DIV height dynamically

DarkFlame

11:22 pm on Jun 3, 2009 (gmt 0)

10+ Year Member



@htdawg: Will read that link more indepth. Thanks for your time

@swa66: Thank you,..I gleaned what I could and fixed the problem in FireFox, however it now doesn't wrap the content, only the viewport. I will try to figure out a work around.

@superds: I am very sorry, I am quite new to CSS and alot of what has been said so far made little sense to me. I really don't know what you mean. Please expand or provide an example.

swa66

2:23 am on Jun 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure what you mean by
it now doesn't wrap the content, only the viewport

In the example I gave, I pushed the content in the wrapper aside by using padding ...

DarkFlame

1:44 am on Jun 7, 2009 (gmt 0)

10+ Year Member



I mean that if the content requires me to scroll down to view, the .side and .bound will only be the size of the viewport, and the content will stretch outside the size of the .bound border

I am guessing that is caused by something else though.

swa66

12:30 pm on Jun 7, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's your height: 100%, use min-height:100% on the element itself and height:100% on *all* parents.

Trip it back to height:100% for IE6 (in a conditional comment) IE6 just is broken by design in this.

DarkFlame

3:16 am on Jun 8, 2009 (gmt 0)

10+ Year Member



Thanks a bunch swa66,..you have really been a brilliant help :D