Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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="first-popup">
 <div class="first-popup__inner">
  <div class="first-popup__title">初回限定クーポン</div>
  <div class="first-popup__body">
   <p class="first-popup__text">当サイトにアクセスいただきありがとうございます。<br>
   初回限定30%OFFクーポンをプレゼントさせていただきます。
  </p>
   <div class="first-popup__limit">2022年6月30日まで</div>
  </div>
  <div class="first-popup__close">×</div>
 </div>
</div>
              
            
!

CSS

              
                .first-popup{
 left: 0;
 top: 0;
 right: 0;
 bottom: 0;
 width: 100%;
 height: 100%;
 background: rgba(0,0,0,.5);
 position: fixed;
 display: flex;
 align-items: center;
 justify-content: center;
}
.first-popup__inner{
 width: 500px;
 height: 200px;
 padding: 35px;
 border-radius: 15px;
 background: #fff;
 box-shadow: 0 0 15px rgba(0,0,0,.1),0 5px 10px rgba(0,0,0,.25);
 display: flex;
 align-items: center;
 justify-content: center;
 flex-direction: column;
 position: relative;
}
.first-popup__title{
 width: 100%;
 margin-bottom: 5px;
 padding-top: 15px;
 padding-bottom: 15px;
 line-height: 1;
 background: #eee;
 text-align: center;
 font-weight: bold;
}
.first-popup__body{
 text-align: center;
}
.first-popup__text{
 text-align: center;
}
.first-popup__limit{
 padding: 5px 15px;
 border-top: 1px dashed #ccc;
 border-bottom: 1px dashed #ccc;
 color: #dc5a45;
 display: inline-block;
 text-align: center;
}
.first-popup__close{
 width: 40px;
 height: 40px;
 border-radius: 50%;
 z-index: 6000;
 right: -20px;
 top: -20px;
 position: absolute;
 color: #fff;
 font-weight: bold;
 background: #333;
 display: flex;
 align-items: center;
 justify-content: center;
 cursor: pointer;
 transition: .2s all ease;
 box-shadow: 0 0 2px rgba(0,0,0,.1),0 5px 5px rgba(0,0,0,.25);
}
.first-popup__close:hover{
 opacity: .6;
}
              
            
!

JS

              
                $(function(){
  // 初回アクセス時
  if (document.cookie.indexOf('visited=yes') === -1) {
    document.cookie = 'access=yes path=/';
    //conlose.log('初回のアクセスです');
  }else{
    // 2回目以降のアクセス
    //conlose.log('2回目以降のアクセスです');
    $(".first-popup").css({"display":"none"});
  }
  
  // クーポンを消す
  $(".first-popup__close").on("click",function(){
    $(".first-popup").stop().fadeOut();
  });
});
              
            
!
999px

Console