I am trying to position a page footer div at the bottom of a web page, right underneath a main content div which is positioned absolutely, and will mostly be 350px high, but on one page will need to be flexible to accommodate more content. Positioning absolutely won’t work for this flexibility of course, but when I’ve tried positioning relatively, it seems to ignore the content div and positions it relative to the top of the page.
Perhaps complicating things is that the footer, along with the banner images and main navigation, are PHP includes, so they can be updated across all pages at once if needed at some point. The content div is coded on each page, since each page will have different copy.
I’ve tried clear:both; on both the content div and the footer div, but it doesn’t help. I tried position:absolute; bottom:30px; instead of positioning from the top, but that puts the footer 30px from the bottom of the browser window instead of the bottom of the page, regardless how long the page is – so I have the footer in the middle of the content. Position:relative; bottom:30px; puts it back at the top of the page.
I’m at a loss. I don’t even know what to google at this point. Why is it ignoring the content div? How can I get it to position underneath it, regardless how long it is?
The php doesn’t matter as it’s processed server side and the resulting page is static by the time it reaches the browser.
In your example, I am not sure why anything needs positioning. Remove all the positioning CSS and it should flow just fine.
As to why what you are doing isn’t working - relative positioning is relative to the natural position of the element, not the previous element - a subtle but sometimes important distinction. It mostly becomes important if the ‘content’ of the previous element is malformed, which given the behavior described (relative jumping to top of the page) is likely what your problem is.
They need to be positioned so that they don’t lie on top of the navigation menu on the left or the banner images on the top. Removing the positioning from the footer and content divs puts them up at the top left.
I’m not sure what you mean by the content being malformed. It is literally just the <h1> tags and a couple sets of <p> tags. Aside from the copy being different, it’s exactly what you see above.
Malformed means invalid html/xml - you can test a page to see if it’s malformed pretty easily using the W3C tool: http://validator.w3.org/
If that’s not helpful I’d have to actually load your code up and start playing around with it, and I’m not really up for that at the moment (sorry) Perhaps someone else can chime in.
Don’t absolutely position the footer. And instead of top and left, use margin-top/margin-left or padding-top/padding-left. That’ll give you the relativistic spacing you want. It might also help to put the footer as a div INSIDE the content instead of after it (hard to say without seeing your complete design).
If you show me a screenshot with the elements clearly identified – or better yet, the complete page, images and navbar included – I can more precisely fix the CSS for ya.
I have not tried putting the include inside the content div… I suppose I could. I’m holding off for now as I’m not sure how much media he’s planning to put on the media page, which may not require messing with the footer positioning at all.
It would be nice to know for future reference, though.
A min-height and a clearfooter div in the right arrangement does the trick. No matter how much content there is, if it’s less than a page’s worth it’s at the botom of the browser, if there’s more than a page’s worth it’s placed at the end of the content div.
Edit your css so that
a) Most of the #content attributes are moved to #layout
b) The 350px height is kept in #content but changed to min-height
c) The footer loses its absolute positioning and is given a 100% width
This should flow with any amount of text in #content. If I were you I’d spend a few minutes to make the entire size out of margins and not absolute positioning (it’s easier to work with that way), but it’s not entirely necessary.
However, the min-height attribute for #content doesn’t seem to work. Checking it with Firebug, that part of the style sheet is showing up like this, as if the attribute isn’t in the stylesheet:
#content {
}
So, for the index page which has less copy, the #content computes to 226px and the footer is up in the middle of the page.
I’ve already tried adding min-height to #layout (both as-well-as #content, and instead of #content) but it renders the same way.
It’s not a total deal-killer – it’s better than the alternative – but if there’s something I can do to correct it I’d like to.
ETA: and of course I see it as soon as I post it. Let me remove that extra : and get back to you.
Okay, I got it. It wasn’t the extra colon either (although that didn’t help). I’d gotten confused about the order in which to close the div tags, so the #footer include ended up inside #content, too, instead of outside of it and inside #layout.
So, while I wait on a response to my support ticket, does anyone have any guesses as to why a form processing script works fine on my hosting server, but not on the client’s? Both servers run PHP5. The client’s host is Dreamhost, if it matters.
You mean the blank thank you page? What’s the source code or name of the script you’re using?
Did you check Dreamhost’s options for PHP in the control panel? Sometimes the exact version number (5.2, 5.3) or other settings can make a difference.
You can make a phpinfo page on both hosts to compare the configuration differences. Also, Dreamhost, has one of the more popular hosts, has a lot of useful forum and wiki posts. Try Googling for the name of your script or the error message + Dreamhost to see if anything comes up.
Not getting an error message, just the blank page. The Captcha widget works fine, btw, if I remove the form processing script it works as expected. Add the processor back in and I get the blank thank you page, and it doesn’t process/email the form info.
Dreamhost is set to PHP 5.2 FastCGI. I have no idea what the FastCGI thing is. Mine is PHP 5.2 too.
It’s the “else if” stuff that’s causing problems. Remove everything below that and the page comes up not blank, although of course the info doesn’t get processed.
My understanding of PHP is pretty limited. I basically grabbed this processing script from the website of my then-employer some years, which had been written by the programmer who’d built the website (and left before I got there, so I was tasked with website updates). I don’t have enough programming knowledge to build a new script from scratch.