<div class="custom-popup-text"> <p> click a box to view a project </p> <a href="#" class="close">ok</a> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> $(document).ready(function(){ $('.close').click(function(){ $('.custom-popup-text').addClass('remove-text'); }); }); </script> <style> div.custom-popup-text { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 900px; min-width: 250px; background-color: #684ce7; border: 2px solid black; z-index: 999999999; text-align: center; padding: 10px; border-radius: 10px; } div.custom-popup-text a { border: 1px solid black; padding: 5px 20px; display: inline-block; margin-bottom: 20px; border-radius: 10px; } .remove-text {display: none !important;} </style>