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

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="notify" id="notify"><span id="notifyType" class="notifyType"></span></div>
              
            
!

CSS

              
                // Game Colours
$brown: #cca267;
$red: #dd5b5b;
$grey: #666666;

.notify{  
    position:absolute;
    top:0px;
    width:100%;
    height:0;  
    box-sizing:border-box;
    color:white;  
    background: $brown;
    text-align:center;
    overflow:hidden;
    box-sizing:border-box;
    transition:height .2s;
    font-size: 2em;
  }
  
  #notifyType:before{
    display:block;
  }
  
  .active{  
    height:50px;
  }

  .matched:before{
    padding-top: 15px;
    padding-bottom: 15px;
    background: $brown;
    Content:"Aww Yeaaaaa! Excellent Job!";
  }

  .tenturns:before{
    background: $red;
    padding-top: 15px;
    padding-bottom: 15px;
    Content:"Watch out! You have 10 turns left!";
  }

  .fifteenturns:before{
    background: $red;
    padding-top: 15px;
    padding-bottom: 15px;
    Content:"Try harder! 5 turns left!";
  }


              
            
!

JS

              
                let notify = document.getElementById('notify');
let notifyType = document.getElementById('notifyType');

if(cardNumber1 === cardNumber2){
  
              // Shows Notification bar with the 'matched' class
                notify.classList.add("active");
                notifyType.classList.add("matched");
  
              // Disappears after 2 seconds
                setTimeout(function(){
                notify.classList.remove("active");
                notifyType.classList.remove("matched");
                },2000);
            
               // Other updates when there's a match - irrelevant to notification bar feature
                this.stats.matches++;
               
                this._updateElement(this.el.matches, this.stats.matches);
                
                this.openCards = [];
                
                if(this.stats.matches === this.winMatches){
                    this._endGame(true);
                }
            }else{
               // Updates when it is not a match - irrelevant to notification bar feature
                this.stats.misses++;
                const that = this;
                setTimeout(function(){
                    that.openCards[0].removeClass('open');
                    that.openCards[1].removeClass('open');
                    
                    that.openCards = [];
                    
                    if(that.stats.turns >= 20) {
                        that._endGame(false);

                    }
                }, 1000)

              // Show Notification bar with 'tenturns' class, when the 'turns counter' is 10
                if(this.stats.turns === 10 ){
                    notify.classList.add("active");
                    notifyType.classList.add("tenturns");
                  
              // Disappears after 2 seconds
                    setTimeout(function(){
                    notify.classList.remove("active");
                    notifyType.classList.remove("tenturns");
                    },2000);
                }
                
              // Show Notification bar with 'fifteenturns' class, when the 'turns counter' is 15
                if(this.stats.turns === 15 ){
                    notify.classList.add("active");
                    notifyType.classList.add("fifteenturns");
    
                 // Disappears after 2 seconds
                    setTimeout(function(){
                    notify.classList.remove("active");
                    notifyType.classList.remove("fifteenturns");
                    },2000);
                }
}

              
            
!
999px

Console