-1

I am looking to achieve a 45 degree angle pie slice from this 90 degree angle slice. I want to keep the starting point of the curve at the bottom left.

The code I have is as follows:

.quarter-circle{
  width: 100px;
  height: 100px;
  background: orange;
  border-radius: 100px 0 0 0;
  -moz-border-radius: 100px 0 0 0;
  -webkit-border-radius: 100px 0 0 0;
}
<div class="quarter-circle"></div>

http://jsfiddle.net/5etm63fg/

yunzen
  • 32,854
  • 11
  • 73
  • 106
Matt Jameson
  • 582
  • 3
  • 16
  • you will ned completly different code. you can not achieve this by modifying the numbers in your sample – Philipp Sander Oct 18 '18 at 11:21
  • It requires minor changes to your HTML, but take a look at this: https://stackoverflow.com/a/14185845/1650337 – DBS Oct 18 '18 at 11:37

4 Answers4

2

It can be done using linear-gradient. Instead of focusing on the 45deg slice, think it other way around.

.quarter-circle{
     width: 300px;
     height: 300px;
     background: orange;
     border-radius: 50%;
     background-image: linear-gradient(0deg, white 50%, transparent 50%), linear-gradient(45deg, transparent 50%, white 50%);
}
<div class="quarter-circle"></div>

Check the JS fiddle: http://jsfiddle.net/eL1jsm20/2/

Rahul Gandhi
  • 1,035
  • 1
  • 11
  • 24
1

.eight-circle {
  position: relative;
  width: 100px;
  height: 100px;
  overflow: hidden;
}
.eight-circle:after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background: orange;
  border-radius: 100px 0 0 0;
  -moz-border-radius: 100px 0 0 0;
  -webkit-border-radius: 100px 0 0 0;
  transform: rotate(-45deg);
  transform-origin: 100% 100px;
}
<div class="eight-circle"></div>
yunzen
  • 32,854
  • 11
  • 73
  • 106
0

Poorly supported at present (Chrome only) but CSS Level 4 conic-gradient can do that...or use a polyfill.

Chrome only demo.

.quarter-circle {
  width: 300px;
  height: 300px;
  background: conic-gradient(transparent 75%, orange 75%, orange 87.5%, transparent 87.5%);
  border-radius: 50%;
  margin: 1em auto;
}
<div class="quarter-circle"></div>
Paulie_D
  • 107,962
  • 13
  • 142
  • 161
0

Try this Added some before tricks

.quarter-circle{
     width: 100px;
     height: 100px;
     background: orange;
     border-radius: 100px 0 0 0;
     -moz-border-radius: 100px 0 0 0;
     -webkit-border-radius: 100px 0 0 0;
     transform: rotate(90deg);
     position:relative;
     
}

.quarter-circle::after{
content:""; 
position:absolute; 
border:39px solid #fff; 
left:0; 
top:0; 
border-color:transparent #fff; 
border-width:100px 0 0 100px;
}
<div class="quarter-circle"></div>
Viira
  • 3,805
  • 3
  • 16
  • 39