LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code
CSS
body {
  background: rgba(0, 0, 0, .05);
}

header {
  width: 100%;
  background: white;
  height: 80px;
  border-bottom: solid 1px rgba(0, 0, 0, .1);
  box-shadow: 0 0 10px 5px rgba(0, 0, 0, .05);
}

.user-bar {
  float: right;
  margin: 20px;
  width: 150px;
  height: 40px;
  border-radius: 5px;
  border: solid 1px rgba(0, 0, 0, .05);
  background: rgba(0, 0, 0, .05);
}

.button {
  position: relative;
  width: 33.333%;
  height: inherit;
  float: left;
  font-size: 18px;
  text-align: center;
  line-height: 41px;
  color: rgba(0, 0, 0, .3);
  text-shadow: 1px 1px 0 white;
  cursor: pointer;
  box-sizing: border-box;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  transition: all .3s;
  -moz-transition: all .3s;
  -webkit-transition: all .3s;
}

.button:first-child {
  border-left: none;
  border-radius: 5px 0 0 5px
}

.button:last-child {
  border-radius: 0 5px 5px 0;
}

.button.notifications {
  color: rgba(255, 0, 0, .7);
}

.button.messages {
  color: rgba(0, 0, 255, .7);
}

.button[counter="0"] {
  color: rgba(0, 0, 0, .3);
}

.button[counter]::after {
  opacity: 1;
  content: attr(counter);
  position: absolute;
  top: -15px;
  left: -10px;
  font-family: Arial;
  font-size: 12px;
  color: white;
  width: 25px;
  height: 25px;
  line-height: 24px;
  text-align: center;
  text-shadow: none;
  border-radius: 50% 50% 0 50%;
  transition: all .3s;
  -moz-transition: all .3s;
  -webkit-transition: all .3s;
}

.button.notifications[counter]::after {
  background: rgb(255, 70, 70);
}

.button.messages[counter]::after {
  background: rgb(70, 70, 255);
}

.button[counter="0"]::after {
  opacity: 0;
}

.button:hover {
  color: #777;
  text-shadow: none;
}

.button.notifications:hover {
  background: rgb(255, 70, 70);
  color: white;
}

.button.messages:hover {
  background: rgb(70, 70, 255);
  color: white;
}

.button.notifications[counter="0"]:hover {
  color: rgb(255, 70, 70);
  background: transparent;
}

.button.messages[counter="0"]:hover {
  color: rgb(70, 70, 255);
  background: transparent;
}

@-webkit-keyframes rotating {
    0% {
        -webkit-transform: rotate(0deg);
    }
    30% {
        -webkit-transform: rotate(360deg);
    }
    31% {
      -webkit-transform: rotate(0deg);
    }
}

.fa-refresh {
    background: none;
    transition: none;
    color: #777 !important;
    
    -webkit-animation: rotating 2s linear infinite;
}
JS
console.clear();

(function (w, d) {
  
  var notifications = d.querySelector('.notifications'),
      messages = d.querySelector('.messages');
  
  function userBarButtonClicked() {
    var item = this;
    callItem.call(item);
    clearCounter.call(item);
    setTimeout(function () {
      showItem.call(item);
    }, 2000);
  }
  
  function callItem() {
    this.classList.remove('fa-bell');
    this.classList.remove('fa-envelope');
    this.classList.add('fa-refresh');
  }
  
  function showItem() {
    this.classList.remove('fa-refresh');
    if (this.classList.contains('notifications')) {
      this.classList.add('fa-bell');
    }
    if (this.classList.contains('messages')) {
      this.classList.add('fa-envelope');
    }
  }
  
  function clearCounter() {
    this.setAttribute('counter', 0);
  }
  
  function populateCounters () {
    notifications.setAttribute('counter', 10);
    messages.setAttribute('counter', 1);
  }
  
  setTimeout(populateCounters, 500);
  
  notifications.addEventListener('click', userBarButtonClicked, true);
  messages.addEventListener('click', userBarButtonClicked, true);
  
})(window, document)
Term
Mon, 11/27/2017 - 21:26

Related Codes

Pen ID
Pen ID
Pen ID
Square Adv