Warm tip: This article is reproduced from serverfault.com, please click

rounded-borders

发布于 2020-11-28 01:07:56

I am trying to round the top & bottom edges of this polygon to be the same as the icon. Does somebody know what I am doing wrong?

.activity {
  max-width: 200px;
}
.activity__icon {
  border-right-radius: 50%;
  text-align: center;
  background-color: #eee;
  clip-path: polygon(50% 20%, 100% 50%, 50% 80%, 0% 50%);
  margin: 0 auto;
  padding: 2rem;
}
.activity__icon i {
  color: #707070;
  border: 2px solid #707070;
  border-radius: 50%;
  max-width: fit-content;
  padding: 15px;
  font-size: 25px;
  text-align: center;
  vertical-align: middle;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
<div class="activity"> 
<div class="activity__icon">
<i class="fas fa-play-circle"></i>
</div>

https://codepen.io/avashavash/pen/OJRPJNL

Questioner
avashavash
Viewed
0
Temani Afif 2020-12-03 22:51:16

You cannot round polygon so here is a different idea using transformation:

.activity {
  width: 200px;
}

.activity__icon {
  text-align: center;
  margin: 0 auto;
  padding: 2rem;
  position:relative;
  z-index:0;
}
.activity__icon::before {
  content:"";
  position:absolute;
  z-index:-1;
  width:141px;  /* 200px / sqrt(2) */
  height:141px; /* 200px / sqrt(2) */
  left:50%;
  top:50%;
  background-color: #eee;
  transform:translate(-50%,-50%) rotate(45deg) rotate3d(1,-1,0,65deg);
  border-radius: 28px 0 20px 0;
}

.activity__icon i {
  color: #707070;
  border: 2px solid #707070;
  border-radius: 50%;
  padding: 15px;
  font-size: 25px;
  text-align: center;
  vertical-align: middle;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
<div class="activity">
  <div class="activity__icon"><i class="fas fa-play-circle"></i>
  </div>