cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div class="notifier">
        <div class="notifier_content">
            <div class="lds-css">
                <div class="lds-ripple">
                    <div></div>
                    <div></div>
                </div>
            </div>
            <span></span>
        </div>
    </div>
            
          
!
            
              body {
    font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
    font-size: 13px;
    background-color: #fafafa;
}

.notifier {
    display: none;
    left: 838px;
    color: #fff;    
    position: fixed;
    min-height: 22px;
    text-align: center;
    background-color: #555;
    top: 24px;
    border-radius: 3px;
    z-index: 20000;
    -webkit-transition: opacity .25s ease-in;
    transition: opacity .25s ease-in;
    -webkit-box-shadow: rgba(0,0,0,0.156863) 0 2px 3px 0, rgba(0,0,0,0.0588235) 0 1px 10px 0, rgba(0,0,0,0.0196078) 0 4px 6px 0;
    box-shadow: rgba(0,0,0,0.156863) 0 2px 3px 0, rgba(0,0,0,0.0588235) 0 1px 10px 0, rgba(0,0,0,0.0196078) 0 4px 6px 0;
}

.notifier.success {
    background: #d6e9c6;
    color: #468847;
}

.notifier.error {
    background: #ec8787;
    color: #551313;
}

.notifier.warning {
    background: #f8ecad;
    color: #7c6d1f;
}

.notifier .notifier_content {
    white-space: nowrap;
    padding: 12px 20px;
    display: block;
    margin-top: 1px;
    position: relative;
}

.notifier .notifier_content span {
    margin-left: 23px;
    margin-right: 23px;
}

.lds-css {
    display: none;
    position: absolute;
    left: 8px;
    top: 4px;
    transform: scale(0.16);
}

@-webkit-keyframes lds-ripple {
0% {
    top: 90px;
    left: 90px;
    width: 0;
    height: 0;
    opacity: 1;
  }
  100% {
    top: 15px;
    left: 15px;
    width: 150px;
    height: 150px;
    opacity: 0;
  }
}
@keyframes lds-ripple {
  0% {
    top: 90px;
    left: 90px;
    width: 0;
    height: 0;
    opacity: 1;
  }
  100% {
    top: 15px;
    left: 15px;
    width: 150px;
    height: 150px;
    opacity: 0;
  }
}
.lds-ripple {
  position: relative;
}
.lds-ripple div {
  box-sizing: content-box;
  position: absolute;
  border-width: 10px;
  border-style: solid;
  opacity: 1;
  border-radius: 50%;
  -webkit-animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
  animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
.lds-ripple div:nth-child(1) {
  border-color: #ffffff;
}
.lds-ripple div:nth-child(2) {
  border-color: #ffffff;
  -webkit-animation-delay: -0.5s;
  animation-delay: -0.5s;
}
            
          
!
            
              class Connection {
    constructor() {
        this.options = {
            onlineText: 'Your device is connected to the internet.',
            offlineText: 'Your device lost its internet connection.',
            reconnectText: 'Attempting to reconnect...',
            notifier: document.querySelector('.notifier'),
            notifierText: document.querySelector('.notifier span'),
            spinner: document.querySelector('.notifier .lds-css')
        };

        this.init();
    }

    init() {
        if (navigator.onLine) {
            this.on();
        } else {
            this.off();
            setTimeout(() => {
                this.reconnect();
            }, 1500);
        }

        window.addEventListener('online', () => {
            this.on();
        });

        window.addEventListener('offline', () => {
            this.off();
            setTimeout(() => {
                this.reconnect();
            }, 1500);
        });
    }

    on() {
        this.options.notifierText.innerText = this.options.onlineText;
        this.options.notifier.classList.remove('error', 'warning');
        this.options.notifier.classList.add('success');
        this.options.notifier.style.display = "block";
        this.options.spinner.style.display = "none";
    }

    off() {
        this.options.notifierText.innerText = this.options.offlineText;
        this.options.notifier.classList.remove('success', 'warning');
        this.options.notifier.classList.add('error');
        this.options.notifier.style.display = "block";
        this.options.spinner.style.display = "none";
    }

    reconnect() {
        this.options.notifierText.innerText = this.options.reconnectText;
        this.options.notifier.classList.remove('error', 'success');
        this.options.notifier.classList.add('warning');
        this.options.notifier.style.display = "block";
        this.options.spinner.style.display = "block";
    }
}

(function () {
    new Connection();
})();
            
          
!
999px
Loading ..................

Console