slider clip css

by amindunited

HTML

<div class="container">
  <div class="slider"> &nbsp; </div>
</div>

CSS

.container {
  display: flex;
  align-items: center;
  background-color: rebeccapurple;
  height: 46px;
  width: 280px;
  border-radius: 23px;
  padding: 2px;
  justify-content: flex-end;
}

.slider {
  position: relative;
  /* width: 5.5em; */
  width: 2rem;
  
  background-size: 200% 200%;
  background-position: 99% 0;
  border-radius: 0 24px 24px 0;
  padding: 0;
  padding-left: 1.2em;
  padding-right: .8rem;
  align-self: stretch;
  background-image: linear-gradient(90deg, rgba(102,51,153,1) 50%, rgba(255,255,255,1) 50%);
  clip-path: polygon(20% 0%, 100% 0, 100% 100%, 0% 100%);
  transition: background 200ms ease-in-out;
  
}



.container:hover .slider {
  /* transition: background 200ms ease-out; */
  background-image: linear-gradient(90deg, rgba(102,51,153,1) 50%, rgba(255,255,255,1) 50%);
  background-position: 0 0;
  /* clip-path: inset(0 0 0 2rem); */
}