A pure solution to putting your own HTML and CSS to work as a modal dialogue.
by eustasy
Include after jQuery 3 or 4, preferably from jsDelivr. Then add a trigger element with a data-modal-id attribute pointing to the id of the modal element, and initialise leanModal on the trigger's selector. A standard href attribute can be used instead of data-modal-id. The modal can be anywhere in the page.
leanModal doesn't hide the modal before it is opened, so hide it yourself with a single-class rule such as .modal-hidden { display: none; }. An inline style or an ID selector would outrank the class leanModal adds on opening, and the modal would never appear.
The README has the full documentation: every option, the global options, and how the modal is moved in the page.