ul {
  padding: 0;
  display: flex;
  flex-wrap: wrap;
}
ul li {
  list-style: none;
}
ul li a {
  position: relative;
  display: block;
  margin: 0 10px;
  padding: 5px 10px;
  color: #114A83;
  font-size: 24px;
  text-decoration: none;
  text-transform: uppercase;
  transition: 0.5s;
  overflow: hidden;
}
ul li a::before {
  content: '';
  position: absolute;
  top: calc(50% - 2px);
  left: -100%;
  width: 100%;
  height: 4px;
  background: #2196f3;
  transition: 0.5s;
  border-radius: 5px;
}
#selected, #selected a {
    background: #2196f3;
    border-radius: 5px;
    color: #fff;
    margin: 0 5px;
}
ul li:not(#selected) a:hover {
  color: #fff;
}
ul li:not(#selected) a:hover::before {
  animation: animate .5s linear forwards; 
}

@keyframes animate {
  0% {
    top: calc(50% - 2px);
    left: -100%;
    height: 4px;
    z-index: 1;
  }
  50% {
    top: calc(50% - 2px);
    left: 0;
    height: 4px;
    z-index: 1;
  }
  100% {
    top: 0;
    left: 0;
    height: 100%;
    z-index: -1;
  }
}