Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="popup-overlay">
  <div class="popup">
    <p>If you select "close" a cookie will be created for one minute. If "submit" is selected a cookie will be set for 5 minutes. This can be used to remind users that dont sign up to do it, and stop bugging users that do sign up.</p>
    <a href="javascript:;" class="close">Close</a>
    <a href="javascript:;" class="submit">Submit</a>
  </div>
</div>

              
            
!

CSS

              
                body{
  height:300vh;
  background: linear-gradient(45deg,  violet , dodgerblue, hotpink);
}

.popup-overlay{
  display:none;
  position:fixed;
  top:0;
  left:0;
  rigth:0;
  bottom:0;
  background-color:rgba(0,0,0,.5);
  width:100%;
  height:100%;
  text-align:center;
  padding:1rem;
  align-items:center;
  justify-content:center;
  .popup{
    display:inline-block;
    width:400px;
    min-height:200px;
    background-color:white;
    border-radius: 5px;
    display:flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items:center;
    justify-content:center;
  }
}

p{
  flex: 0 1 100%;
  padding:0 1rem;
  margin:0;
  margin-top:1rem;
  font-family:sans-serif;
}

a.close,
a.submit{
  margin-top:0;
  display:inline-block;
  color:white;
  background-color:#673862;
  border-radius: 5px;
  padding: .25rem 1rem;
  text-decoration: none;
  text-transform: uppercase;
  font-family: sans-serif;
  margin-right:1rem;
  &:last-of-type{
    margin-right:0;
  }
}
              
            
!

JS

              
                jQuery(document).ready(function($) {
  
  //check to see if the submited cookie is set, if not check if the popup has been closed, if not then display the popup
  if( getCookie('popupCookie') != 'submited'){ 
    if(getCookie('popupCookie') != 'closed' ){
      $('.popup-overlay').css("display", "flex").hide().fadeIn();
    }
  }
  
  $('a.close').click(function(){
    $('.popup-overlay').fadeOut();
    //sets the coookie to one minute if the popup is closed (whole numbers = days)
    setCookie( 'popupCookie', 'closed', .00069444444 );
  });
  
  $('a.submit').click(function(){
    $('.popup-overlay').fadeOut();
    //sets the coookie to five minutes if the popup is submited (whole numbers = days)
    setCookie( 'popupCookie', 'submited', .0034722222 );
  });

  function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
      var c = ca[i];
      while (c.charAt(0) == ' ') {
        c = c.substring(1);
      }
      if (c.indexOf(name) == 0) {
        return c.substring(name.length, c.length);
      }
    }
    return "";
  }

  function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = "expires=" + d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
  }
  
});
              
            
!
999px

Console