Hello,
I am trying to design a new layout and then when I viewed it in chrome it was just a blank page. By chance i commented out the Doctype and it is displays fine in chrome now.
The doctype isn’t hte issue. When you have no doctype the browser incorrectly bases percentage heights. Percentage heights should base their height off a parent. In your example, you don’t have a parent height set thus BOTH boxes height should be 0. Now, if you have no doctype the browser gets that wrong.
However, if you do hav a doctype, in order for it to work you need to, first of all, DECLARE a height for the parent :). The html/body need it set.
oh okay. i knew the doctype couldn’t be the problem because that didn’t make sense. Thank you for explaining it to me.
So, in review, am I correct to say that in using percentage values for height and width, the parent element (if there is one) must have some declaration of a height and width?
I declared a 100% height and width and it works just as i hoped! Thank you!
ah okay.
Unfortunately, i am now having one more issue i was hoping you could help me with.
I am trying to add some placeholder content, but, as it should, its appearing on top when I want all of it to be over / in front of the two divs. The two divs were just to split the body’s background into two colours.
Do you have any suggestions on how to get the content on over of a 2-colour-split bg?
Well the problem is is that the top/bottom divs you have there are part of the main flow…which means other content will run on top of it.
I’d honestly not make a page with a 2 colour split, however if you were going to do like…a fading from one color to then next (gradient)…I’d place that on a wrapper div.
Can you show me what overall you’d like your page to look like? A quick mockup in photoshop or paint will suffice. I’d not go for a straight 2 different color design…I imagine it’d look bad.
The bam site… open your favourite browser’s developer toolbar/whatever. Find “container” and you’ll see everyone is sitting centered inside that container.
The divide is made by an image: http://www.bam.com.au/art/homeglow.jpg which sits in #glow, who’s just a parent wrapping #container. When the page is taller than that image, the rest of the dark grey comes from the body’s background. They also have a green repeated 1px thing so you keep getting the same amount of green if your screen is really really wide, on #wrap. I suppose they did that with an image so that #wrap could grow with its content without covering up the grey of the body. So in your case you’d have a purple/indigo image doing the same thing, but be aware your image will be limited in px (not % as you were hoping to use). The other option might be complicated: a box with a set height and forcibly allowing the content inside to spill out, and have that content have its own bg image/colour or something. Because of how IE deals with floats, you can’t take advantage of how floats who are unenclosed to have a float hanging out.
BTW don’t use their retarded push div technology, that was silly when it was new, and it’s sillier now. They’re doing a sticky footer. You’ve prolly seen Paul’s floating around here somewhere before.
I’m assuming this means that you have some strong dislike for it?
The limit of the px in the indigo/purple image’s height is the reason why i didn’t try that what bam did at first. So are you saying that what I am trying to achieve without using images for the bg is impossible?
Also what is push div technology? And, yes, i have seen paul’s sticky footer example.
Speaking of @Paul_O_B maybe he can verify if my idea for this layout is possible with %'s and bg colours? instead of images like bam did.
Hm, no? That’s the url, bam. I didn’t actually read the site, just looked at the code and the colours : )
I wondered. Earlier I saw this thread and thought, an image is stuck in px…
I don’t want to say that. I keep thinking it probably can be done, but it shouldn’t be brittle.
There’s some CSS3 stuff coming out like background-position which can do more than the old background-position, and the gradients have start and stop properties which can be set in %s. In fact, now that I think of it, I’ve seen Lea Verou do % background colours by taking CSS gradients and stopping them in a severe way, so that it’s not really a gradient but a line. I forget now what exactly she did, but I can dig it up. She uses it to make the CSS patterns on her site. Of course, this is CSS3 so we’ll need to think of something else too. What’s cool about the gradients is, they are applied onto “background-image” so you can start with a real image for non-supporting browsers and then override with the gradients. Browsers who support the gradients won’t use the image.
*Edit I was thinking of stuff like this http://lea.verou.me/css3patterns/ but I notice they’re making px-sized gradients and repeating them like images
The bam site is using a div called “push” which is a popular sticky-footer solution floating around on the web. I forget already what the div does, but Paul’s various sticky footers don’t require the extra element. I also notice they had a clearing div too. Tsk tsk.
Oh, okay. I just thought by … you were somehow representing, never-mind i was over-thinking
Ah, yes I have seen her patterns. I am excited to try this way if there isn’t another way, but the only issue, as you said i believe, is support. I’ll tweet her asking about % stopping points.
It needs the one empty div but you can even lose that if you don’t want ie8 and under support and instead use body:after rules to supply the fixed positioned background at the top (IE8 actually supports :after and :before but won’t apply position fixed to the element).
oh okay. wow that is not at all as complicated as I thought it would be. Thank you. Especially for posting this so late, I appreciate you dedication
I would do the second option, but I have just dropped / am starting to drop IE6 support and I think it may be too soon to do it for ie8.
Anyway one can get rid of the vertical scroll bar without just setting overflow-y / overflow to hidden?
Meaning, eventually if there is enough content a scrollbar would be needed, but I was wondering if there was a way to hide the scrollbar while its not needed.
Are you talking about the browser scroll bar or just a regular elements scrollbars?
If you have it set to overflow:auto, as apposed to overflow:scroll, the “auto” will only have scrollbars once the elements dimensions are reached, and “scroll” will show it anyway.
If it’s browser scrollbars, at least in IE8 for IETester, no scrollbars appear to begin with…