We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,078 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Help using JavaScript and CSS together

I am very new to JavaScript and am trying to use JavaScript to determine the height of a div. The div starts in the middle of the browser window and I need it to extend to the bottom of the window. How can the window height be determined and used to accomplish this?

Thanks in advance!

Justin

2
Contributors
4
Replies
1 Day
Discussion Span
1 Year Ago
Last Updated
5
Views
Question
Answered
justinkb88
Newbie Poster
3 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Look at using jQuery.

stbuchok
Practically a Posting Shark
876 posts since May 2011
Reputation Points: 138
Solved Threads: 124
Skill Endorsements: 2

Thanks for the suggestion. I have looked into jQuery today and can use it to find the window and div height, but how can I account for the offset for a centered div?

justinkb88
Newbie Poster
3 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

divide by 2 (half the width of the div)

div.left = (window.width / 2) - (div.width / 2)

That should center the div (you'll want this to happen on the resize event as well).

stbuchok
Practically a Posting Shark
876 posts since May 2011
Reputation Points: 138
Solved Threads: 124
Skill Endorsements: 2

Thanks for leading me in the right direction! I got everything working correctly.

justinkb88
Newbie Poster
3 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 1 Year Ago by stbuchok

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0926 seconds using 2.7MB