1

We have a DIV that is loaded with content based on user options in a form. The DIV can grow to large to be seen on screen as it is also a sticky element and follows the user on the screen.

How would we get the DIV to work out if some of itself is off screen and if so show a button that can then link to the full content.

Any ideas?

Marvellous

Walrus
  • 19,801
  • 35
  • 121
  • 199

3 Answers3

0

if you can force the maximum width of your div, try this with CSS :

max-width: *YOUR_PAGE_WIDTH*px;
Mohammed Swillam
  • 9,119
  • 4
  • 36
  • 47
0

This can be done via CSS,

overflow:auto;
Andrew
  • 13,757
  • 13
  • 66
  • 84
Damian
  • 219
  • 5
  • 14
  • I'm afraid not. Overflow must remail :hidden in order to facilitate the sticky element. I suppose a better way to put it would be can we detect if there is an overflow, and if so enact a script – Walrus Mar 29 '11 at 13:16
0

If you are looking for a JS solution perhaps, this would work:

var topoffset = $div.offset().top;
var height = $div.height();
var pageHeight = $(window).height();

if ((topoffset + height) > pageHeight) {
  //the div is going outside the page
}
sv_in
  • 13,929
  • 9
  • 34
  • 55
  • that should have worked. But I do not think it is calculating the topoffset correctly as the script is being triggered regardless. I tried it without the top offset and the script did not trigger anything – Walrus Mar 29 '11 at 13:33