complete-javascript-course icon indicating copy to clipboard operation
complete-javascript-course copied to clipboard

A question about the overlay of the Modal Window Project

Open bobweein opened this issue 3 years ago • 3 comments

" when we want to click the outside of a modal ,then the modal window closes . "I finished this by following teacher jonas .But i am confused about why we can do that ? the overlay is a empty div ,so why clicking the outside of a modal equals to clicking the empty div container.

bobweein avatar Aug 19 '22 02:08 bobweein

I mean why i clicked the outside of a modal ,i clicked the overlay div . because the overlay div is empty ? what is the edge of this overlay div?

bobweein avatar Aug 19 '22 03:08 bobweein

Overlay div has width and height 100% and class 'hidden' is removed from it too when modal is open. That's why wherever you click outside of the modal window you actually click on that overlay div. Click event on modal itself is not counted as click on overlay div because of the z-index property in css. Hope it helps.

velinnakov avatar Aug 24 '22 10:08 velinnakov

Overlay div has width and height 100% and class 'hidden' is removed from it too when modal is open. That's why wherever you click outside of the modal window you actually click on that overlay div. Click event on modal itself is not counted as click on overlay div because of the z-index property in css. Hope it helps.

Get it ,Thank you for helping !!!!!

bobweein avatar Aug 26 '22 03:08 bobweein