Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Ashley Dillon
Ashley Dillon
9,092 Points

jQuery overlay size problems

I am trying to integrate a lightbox into a personal project, and I am starting with an overlay. The problem is the overlay will not span the full height of the page.

Here's my code:

jQuery:

var $overlay=$('<div id="overlay"></div>');

$("body").append($overlay);

$overlay.show();

css:

overlay{

background:rgba(0,0,0,0.7); width:100%; height:100%; position:absolute; top:0; left:0; display:none; }

2 Answers

Michal Kurtulík
Michal Kurtulík
9,203 Points

you tray frst row this var $overlay = $('<div id="overlay"></div>');

tomaszklekner
tomaszklekner
10,345 Points

Hi Ashley,

I have successfully integrated the lightbox project to my portfolio.

This var $overlay=$(''); is an empty Jquery object that you are creating, and in consequence you are appending "nothing" to your body tag, it should be:

 var $overlay = $(<div id="overlay"></div>);

Regards,

Tomek