Forum Moderators: not2easy

Message Too Old, No Replies

CSS Learning - Spent all day trying to fix height problem.

CSS height problem

         

Ben878

12:59 am on Jan 7, 2008 (gmt 0)

10+ Year Member



I am only a beginner at css,html php etc. And I have been at my computer all day trying to get this to work and I am seriosley annoyed. I though it would be easy to have a simple background centered behind all my content. But no didnt appear to be that way.

Ok I aren't using a doc type. i know I'm meant to and I will soon. Once I can get this height problem down I will be adding a doc type to my site. Anyway to the problem.

I have my whole site layout pretty much finished and done except. I have it set to a fixed height of 1000px. This is annoying me, I don't want a set height but for my DIV's background to work it seems to be the only way. I have tried I don't know how many times using CSS to make the background work and I have it working but only using height:1000px; So I all my site code within a container DIV. If I set the height to 100% the background shows up until about halfway down the content. So I tried not setting the height and then I don't get anything the DIV's background does not show.

Relevant Html:


<body>
<div id="container">
//Site goes here
</div>
</body>

Relevant CSS:


#container{
position:relative;
width:822px;
top:0px;
margin: -15px auto;
background-image: url(crisscross001.png);
background-repeat: repeat;
border-style: solid;
border-width: 0px 3px 3px 3px;
border-left-color: #808080;
border-right-color: #808080;
border-bottom-color: #808080;
}

I've spent absolutely hours trying to do it. So any help would be greatly appreciated.

[edited by: SuzyUK at 1:35 am (utc) on Jan. 7, 2008]
[edit reason] examplified url [/edit]

Ben878

1:17 am on Jan 7, 2008 (gmt 0)

10+ Year Member



Never mind.... I cheated... a bit:P

But I'm still having a similar problem I want to set the height of one table to height 100% but it seems to be only doing 100% of the space the table needs needs. Not filling the 100% of the DIV tag. Which is itself set to 100%.

vincevincevince

2:02 am on Jan 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



CSS and in fact HTML in general do not always react as you might expect to 100% height for the top level element. In many cases you get 100% of the body, which is the minimum size of browser window which will show the whole page (i.e. could be < or > the actual browser window height)

Regarding background centering did you try:
background-repeat:no-repeat;
background-position:middle center;

?

Ben878

2:40 am on Jan 7, 2008 (gmt 0)

10+ Year Member



I recoded the site and got it working. :) Ive been at the computer for almost 12hours. I might go to bed soon. However I'm having one last problem. My site looks great in every site but IE. IE renders some strange white box over the top part of the layout. :/

Thanks for all your help by the way and sorry for posting this topic when I solved it myself. :(
Wish there was an edit post on here.

Xapti

7:21 am on Jan 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You shouldn't even start coding without adding a doctype. Just add one right away, 4.01 transitional is generally fine. Make sure you include the link to the DTD.

The code you gave isn't necessarily everything necessary for your problem. Chances are if you aren't specifying a height for the container, that it's collapsing to zero height due to exclusive use of floats or absolute positioning inside the div.

If you want a background image for the page, why not put it in the body?
You shouldn't ever really be setting the height for things that hold content, or almost anything for that matter.

If this new IE problem with a doctype? adding a doctype may fix it. We'd still need more code to diagnose that problem though. There also is an edit link which works on RECENT posts, to the left of the post (by the name, info, stickymail, etc.) called "owner edit".

[edited by: Xapti at 7:23 am (utc) on Jan. 7, 2008]