1

I have a circle which have both inside and outside box-shadow, but there is 1px unwanted border. Would anyone please help me to understand why this is happening with only circle and share the solution.

.wrapper {
  padding: 30px;
}

.circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 16px #f9f9f9, 0 0 0 16px #f1f1f1;
  background: #32a500;
}
<div class="wrapper">
  <div class="circle"></div>
</div>
Manish Sharma
  • 1,670
  • 14
  • 20

2 Answers2

2

I think box-shadow: inset is messing up with border-radius.

While waiting for other solutions, you can always avoid using inset and apply instead a border, removing manually the 32px (16px + 16px) from the height and width of your div.

.wrapper {
  padding: 30px;
}

.circle {
  border-radius: 50%;
  background: #32a500;
  box-shadow: 0px 0px 0px 16px #f1f1f1;
  border: 16px solid #f9f9f9;
  width: 88px;
  height: 88px;
}
<div class="wrapper">
  <div class="circle"></div>
</div>
Manish Sharma
  • 1,670
  • 14
  • 20
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • 1
    Thanks @Andrea Ligios. your answer is very helpful, with help of your answer i find one more solution or can say a small updation in your. answer.I add box-sizing so we not need to recalculate height width for border.check this one http://jsfiddle.net/EFRke/4/ – Manish Sharma May 02 '13 at 12:47
  • Great, +1 to border-box :) – Andrea Ligios May 02 '13 at 13:06
1

updated code with help of @Andrea Ligios

.wrapper {
  padding: 30px;
}

.circle {
  border-radius: 50%;
  background: #32a500;
  box-shadow: 0px 0px 0px 16px #f1f1f1;
  border: 16px solid #f9f9f9;
  width: 120px;
  height: 120px;
  box-sizing: border-box;
}
<div class="wrapper">
  <div class="circle"></div>
</div>
Manish Sharma
  • 1,670
  • 14
  • 20