Expanding DIV how to check when it has exceeded screen size
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
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
}
if you can force the maximum width of your div, try this with CSS :
max-width: *YOUR_PAGE_WIDTH*px;
This can be done via CSS,
overflow:auto;
精彩评论