Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > HTML Padding, if scrollbars?

HTML Padding, if scrollbars?
Thread Tools
mdc
Addicted to MacNN
Join Date: Feb 2003
Location: NY²
Status: Offline
Reply With Quote
Jun 18, 2007, 04:23 PM
 
Does anyone know if it's possible to pad the bottom of my html with blank space, if there are scrollbars on the page?

Take this page on my website for example. There are a lot of comments on the left which cause the page to scroll. Scrolling to the bottom of the page and clicking the "Post Your Thoughts" link loses the effect of the sliding comments form.

I'd like to pad the bottom of the HTML, like body { padding-bottom: 100px; } type thing, but only if there are scrollbars on the page. I don't want the padding to cause scrollbars, and then people scroll to nothing.
Any ideas?
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jun 18, 2007, 04:29 PM
 
Originally Posted by mdc View Post
Does anyone know if it's possible to pad the bottom of my html with blank space, if there are scrollbars on the page?

Take this page on my website for example. There are a lot of comments on the left which cause the page to scroll. Scrolling to the bottom of the page and clicking the "Post Your Thoughts" link loses the effect of the sliding comments form.

I'd like to pad the bottom of the HTML, like body { padding-bottom: 100px; } type thing, but only if there are scrollbars on the page. I don't want the padding to cause scrollbars, and then people scroll to nothing.
Any ideas?

Using Javascript you can determine the height that the user's browser window is set to.

How about feeding a JS function you create the number of comments on the page, and have the function determine whether or not to add the padding based on the average length of a comment? If there are enough comments, you can add that padding via a body onload.

Make sense?
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jun 18, 2007, 04:35 PM
 
IOW:

- php code to determine number of comments: $num_comments = mysql_num_rows($result)
- body onload="myfunction($num_comments)"

Javascript:
function myfunction (num_comments) {
var browserheight = (can't remember this code)
var commentsize = 50; // in pixels
var space_to_allocate = commentsize * num_comments;
if (browserheight < space_to_allocate) {
document.getElementById('divblock').style = padding-bottom:100px; (I think this is right)
}
}

This approach doesn't work well if the user increases their browser font size though. There is no great way to equate browser height to the number of lines required by text.
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jun 18, 2007, 05:16 PM
 
Another way to do this is after the javascript call to expand the comment block, do a window.location.href = #bottomofpage where #bottomofpage is an anchor point set below where the comment block is loaded into.

This may not work well in all browsers, but you could try it.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 11:21 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,