Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Gabriel Rosario
23,602 PointsHow to create a always full width and height div with no background image just a background color?
I'm developing a web site and i don't know who to create a full-screen div with only a line of text. The text should be always centered of the screen no matter the view-port size. I know that I can do the 100% width and height but the height depends on the quantity of content, it's no all 100% my full-screen height. How I can overcome this, please help. Than a lot!!!
6 Answers
Jason Founts
Courses Plus Student 14,384 PointsNeed a bit of clarification. Do you want the div take up the full height and width of the viewport perhaps?
If so, I made a site recently (http://getaftermathapp.com) that does just this using JS (jQuery) to achieve this result. The exact jQuery to detect viewport height is: $(window).height(); Note: it only sets the div height on page load and then adjusts.
Gabriel Rosario
23,602 PointsYes!!! that's really good.
Gabriel Rosario
23,602 PointsYes!!! that's really good.
Gabriel Rosario
23,602 PointsYes!!! that's really good.
Gabriel Rosario
23,602 PointsYes!!! that's really good.
Jason Founts
Courses Plus Student 14,384 PointsCool, glad to hear. :D