Jump to content

Creating a text box with a "close" button

Recommended Posts

Hey there, 

Im trying to create a very simple box with text to go over a shop page that can be closed if the user doesn't want to see it. Everything seems to work fine except the "x" button doesnt seem to work on squarespace, though it works in the codepen (I converted the less to css). Any help would be greatly appreciated. 

Here's the code: 

<style>#popup-holder {
     position: absolute;
     top: 100px;
     height: 200px;
     width: 100%;
 #popup-holder.hide {
     display: none;
 #popup-box {
     width: 200px;
     height: 200px;
     position: relative;
     margin: 0px auto;
     background: white;
     border-style: solid;
     border-color: #1d1e21;
     border-width: 4px;
 #popup-box p {
     font-size: 1.5em;
     color: black;
     font-family: sans-serif;
     text-align: center;
     padding-top: 3em;
     padding-bottom: 3.5;
 #popup-box button {
     border-radius: 0px;
     border: none;
     background: transparent;
     font-size: 2em;
     color: black;
     position: absolute;
     right: 0;
     top: 0;
     cursor: pointer;
     padding: 2px 15px 8px 15px;
 #popup-box button:hover, #popup-box button:focus {
     background: rgba(255,255,255,0.4);
 .page-article {
     background-color: #eee;
     width: 70%;
     margin: 30px auto;
     padding: 20px;
     font-family: sans-serif;
     min-height: 100px;
 .page-article a {
     color: #000;
     text-decoration: none;
 .page-article a:hover, .page-article a:focus {
     text-decoration: underline;



$('#exit-popup').click( function() {
  $('#pa-2 a').focus();

setTimeout( function() {
}, 3000);



<div id="popup-holder" class="hide">
  <div id="popup-box">
    <button aria-label="Hide popup" id="exit-popup">x</button>

Link to comment
  • Replies 3
  • Views 1.8k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 1 year later...

I love your code! I tried it and had the same problem. My husband figured it out: The problem is the code you use to make the X on the button. If we used a <button...></button> the X only refreshes the page. Try making it an <input type=button ...> and see if that helps things along:

<input type=button label='Hide popup' id='exit_popup' value='X'>

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.