tags:

views:

458

answers:

3

I am rather new to complex CSS, and have a question- I have a page which positions a floating element along the bottom of the page. It does so by setting the Bottom: 0, and Position: Absolute.

When the user resizes their browser to a very-small size, this element covers up other content on the page.

Ideally, The element would continue to float at the bottom of the browser at normal and large sizes, but if the browser window were to be shrunk too small, the browser would force a scrollbar, instead of moving the floating element any further.

Essentially, I want to tell the browser- No matter how small the window is, never render the page smaller than 800x600.

+1  A: 

You could set html, body { min-width: 800px; min-height: 600px; }

YMMV in different browsers though.

Greg
Perhaps I'm doing it wrong ? body { min-width: 800px; min-height: 600px; }(HTML set the same. Snip for character count)The floating footer still stays at the bottom of the window, and moves over and past both the other elements and the top of the screen.
A: 

It really depends on whether the floating footer needs to always be visible or if it can scroll off the bottom when the browser window is small.

I think some javascript might be easier to manage than a css solution. Keep in mind that min-width and min-height don't work in all browsers.

You can use jquery to make this easier. The $(window).resize( callback ) can be used to set a callback function to handle window resizing.

I use the window dimensions as part of my resize code also. var wh = Math.max(600,$(window).height()); var ww = Math.max(800,$(window).width());

Then I can set the size of a div in my page based on the window size. $('div#mydiv').css('width',ww); You can also set the value to auto to unset your specified value.

Mnebuerquo
I think it's sad that there isn't a clean CSS solution, but you may be right.I'm certainly fine with having the footer scroll off the bottom after a certain size; That's the preferred behaviour in this instance. I had thought of trying a JS solution, and it may be the only choice I have. Thanks.
A: 

I know it is a bit of a cheat but you can use the old trick of putting in an image that is of the required minimum width in the floating element, and the same colour as it. It is then effectively invisible, but prevents the element, and therefore the whole page, from shrinking.

Thanks! I thought of that too- The problem is that the image is just pushed "past" the top of the browser, off the screen; It doesn't prevent the footer from getting too high, and it doesn't set the minimum render height ;(
OOps. Sorry. I'll have a check with the type of footer you're using and see what works!