193193 width : 100% ;
194194 background-color : # eee ;
195195 }
196+
197+ /* The Modal (background) */
198+ .modal {
199+ display : none;
200+ /* Hidden by default */
201+ position : fixed;
202+ /* Stay in place */
203+ z-index : 1 ;
204+ /* Sit on top */
205+ left : 0 ;
206+ top : 0 ;
207+ width : 100% ;
208+ /* Full width */
209+ height : 100% ;
210+ /* Full height */
211+ overflow : auto;
212+ /* Enable scroll if needed */
213+ background-color : rgb (0 , 0 , 0 );
214+ /* Fallback color */
215+ background-color : rgba (0 , 0 , 0 , 0.4 );
216+ /* Black w/ opacity */
217+ }
218+
219+ /* Modal Content */
220+ .modal-content {
221+ background-color : # fefefe ;
222+ margin : 15% auto;
223+ /* 15% from the top and centered */
224+ padding : 20px ;
225+ border : 1px solid # 888 ;
226+ width : 80% ;
227+ /* Could be more or less, depending on screen size */
228+ }
229+
230+ /* The Close Button */
231+ .close {
232+ color : # aaa ;
233+ float : right;
234+ font-size : 28px ;
235+ font-weight : bold;
236+ }
237+
238+ .close : hover ,
239+ .close : focus {
240+ color : black;
241+ text-decoration : none;
242+ cursor : pointer;
243+ }
196244 </ style >
197245</ head >
198246
@@ -223,7 +271,20 @@ <h2 class="sub-headline">
223271 ctx . fill ( ) ;
224272 ctx . stroke ( ) ;
225273 </ script >
274+
275+ <!-- The Modal -->
276+ < div id ="myModal " class ="modal ">
277+
278+ <!-- Modal content -->
279+ < div class ="modal-content ">
280+ < span class ="close "> ×</ span >
281+ < p > Some text in the Modal..</ p >
282+ </ div >
283+
284+ </ div >
285+
226286 < div class ="content " id ="haha ">
287+ < button id ="myBtn "> Open Modal</ button >
227288 < a href ="https://www.google.com "> asdf asfasdfasfdasdf</ a >
228289 < div class ="skeleton-text "> </ div >
229290 < div class ="skeleton-text "> </ div >
@@ -234,6 +295,35 @@ <h2 class="sub-headline">
234295 < div class ="skeleton-text "> </ div >
235296 </ div >
236297
298+ < script >
299+ // Get the modal
300+ var modal = document . getElementById ( "myModal" ) ;
301+
302+ // Get the button that opens the modal
303+ var btn = document . getElementById ( "myBtn" ) ;
304+
305+ // Get the <span> element that closes the modal
306+ var span = document . getElementsByClassName ( "close" ) [ 0 ] ;
307+
308+ // When the user clicks the button, open the modal
309+ btn . onclick = function ( ) {
310+ modal . style . display = "block" ;
311+ }
312+
313+ // When the user clicks on <span> (x), close the modal
314+ span . onclick = function ( ) {
315+ modal . style . display = "none" ;
316+ }
317+
318+ // When the user clicks anywhere outside of the modal, close it
319+ window . onclick = function ( event ) {
320+ if ( event . target == modal ) {
321+ modal . style . display = "none" ;
322+ }
323+ }
324+
325+ </ script >
326+
237327</ body >
238328
239329</ html >
0 commit comments