Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw cycle arrow in CSS?

Tags:

css

css-shapes

How can I draw a cycle arrow and text on the center just like below image using CSS?

I've tried creating a curve arrow but I don't know how to make it look how I want.

.arrow {
  width: 200px;
  height: 200px;
  border: 6px solid;
  border-radius: 50%;
  position: relative;
}
.arrow:before {
  content: "";
  display: block;
  width: 10px;
  height: 50px;
  background: #fff;
  position: absolute;
  bottom: 0;
  top: 0;
  right: -6px;
  margin: auto;
}
.arrow:after {
  content: "";
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-top: 20px solid #000;
  position: absolute;
  bottom: 106px;
  right: -20px;
}
<div class="arrow"></div>

enter image description here

like image 633
glen.a Avatar asked Dec 18 '22 21:12

glen.a


1 Answers

Here is a crazy idea using multiple background and pseudo elements:

.arrow {
  width:250px;
  height:200px;
  font-weight:bold;
  font-size:1.2em;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:
    radial-gradient(93% 98%   at bottom left,#fff    80%,transparent 81%) 100% -23px,  
    radial-gradient(117% 102% at bottom left,#5dac58 80%,transparent 81%) 100% -23px,
    
    radial-gradient(93% 98%   at top left,#fff    80%,transparent 81%) 100% calc(100% + 23px),  
    radial-gradient(117% 102% at top left,#51884b 80%,transparent 81%) 100% calc(100% + 23px),
  
  
    radial-gradient(93% 98%   at bottom right,#fff    80%,transparent 81%) 0 -23px,  
    radial-gradient(117% 102% at bottom right,#51884b 80%,transparent 81%) 0 -23px,
  
    radial-gradient(93% 98%   at top right,#fff    80%,transparent 81%) 0 calc(100% + 23px),  
    radial-gradient(117% 102% at top right,#5dac58 80%,transparent 81%) 0 calc(100% + 23px);
    
    background-size:50% 60%;
    background-repeat:no-repeat;
    position:relative;
}
.arrow:before,
.arrow:after{
    content: "";
    position: absolute;
    z-index: 2;
    top: calc(50% - 12px);
    border-right: 25px solid #fff;
    border-left: 25px solid #fff;
}
.arrow:before {
    left: -2px;
    border-bottom: 25px solid #5dac58;
}
.arrow:after {
    right: -2px;
    border-top: 25px solid #5dac58;
}
<div class="arrow">
 92.28%
</div>
like image 98
Temani Afif Avatar answered Jan 13 '23 14:01

Temani Afif