0

Hello I would like please your help. I am trying to make round div's (with icons inside) that when the user hover them ,the border will change smooth the border color. I have seen this https://codepen.io/katmai7/pen/jCAhv but I can't make the animation smooth and make the movement begin from center top, then right, then bottom center and then again top.

.wrap_text{
  margin: 0px auto;
  width: 105px;
}

@color: red;

.circle_text {
    position: relative;
    overflow: visible;
    width: 105px;
    height: 105px;
    border-radius: 50%;
    box-shadow: 0px 0px 0 2px #e3e3e3,0px 0px 0 2px #e3e3e3,0px 0px 0 2px #e3e3e3,0px 0px 0 2px #e3e3e3,0 0 0 2px #e3e3e3 !important;  
  
span.text_text {
    position: absolute;
    top: 26px;
    left: 17%;
    width: 60px;
    color: #fff;
    text-align: center;
    text-transform: uppercase;
    font: 18px sans-serif;
    transition: opacity .2s ease;
}
  
  &:hover{
    animation: border .4s ease 1 forwards;
    
    .text_text{
      opacity: 1;
    }
    
  
    
  }
}


@keyframes border{
  0% {
    box-shadow: 60px 60px 0 3px @color, -60px 60px 0 3px @color, -60px -60px 0 3px @color, 60px -60px 0 3px @color, 0 0 0 3px #855f92;
  }
  25% {
    box-shadow: 0 125px 0 3px @color, -60px 60px 0 3px @color, -60px -60px 0 3px @color, 60px -60px 0 3px @color, 0 0 0 3px #855f92;
  }
  50% {
    box-shadow: 0 125px 0 3px @color, -125px 0px 0 3px @color, -60px -60px 0 3px @color, 60px -60px 0 3px @color, 0 0 0 3px #855f92;
  }
  75% {
    box-shadow: 0 125px 0 3px @color, -125px 0px 0 3px @color, 0px -125px 0 3px @color, 60px -60px 0 3px @color, 0 0 0 3px #855f92;
  }
  100% {
    box-shadow: 0 125px 0 3px @color, -125px 0px 0 3px @color, 0px -125px 0 3px @color, 120px -40px 0 3px @color, 0 0 0 3px #855f92;
  } 
}



@keyframes line_text{
  0%{
    right: 60px;
    width: 0;
  }
  100% {
    right: 10px;
    width: 100px;
  }
}
<div class="icon-service">
    <div class="wrap_text">
        <div class="circle_text">
        <span class="text_text"><img src="img.png" alt=""></span>
       </div>
    </div>

Can anyone please help me? Thank you in advance

Black Widow
  • 75
  • 2
  • 10

1 Answers1

0

Based on this previous answer you can achieve this using clip-path and less of code

.box {
  width:150px;
  height:150px;
  margin:20px;
  box-sizing:border-box;
  
  text-align:center;
  font-size:30px;
  line-height:150px;
  position:relative;
  z-index:0;
}
.box:before {
  content:"";
  position:absolute;
  z-index:-1;
  top:0;
  left:0;
  right:0;
  bottom:0;
  border:3px solid #000;
  border-radius:50%;
  transform: scaleX(-1) rotate(45deg);
  clip-path:polygon(50% 50%,0 0,0 0,0 0, 0 0,0 0);
  transition:1s all;
}
.box:hover::before {
  animation:change 1s linear forwards;
  border-color:red;
}

@keyframes change {
  25% {
    clip-path:polygon(50% 50%,0 0,   0 100%,0 100%,0 100%,0 100%);
  }
  50% {
    clip-path:polygon(50% 50%,0 0,0 100%,   100% 100%, 100% 100%,100% 100%);
  }
  75% {
    clip-path:polygon(50% 50%,0 0,0 100%,100% 100%,    100% 0,100% 0);
  }
  100% {
    clip-path:polygon(50% 50%,0 0,0 100%,100% 100%, 100% 0,     0% 0%);
  }
}

body {
 background:pink;
}
<div class="box">
  Hover
</div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415