I'm trying to create a rainbow circle with 8 segments, 45 degrees in size.
You'll notice that the orange segment is double the size of the others. I think these are number 1 and 8. I can't however figure out how to separate them. Are my degree wrong?
Thanks for your help.
body {
overflow: hidden;
}
.pie {
position: relative;
margin: 1em auto;
border: dashed 1px;
padding: 0;
width: 32em;
height: 32em;
border-radius: 50%;
list-style: none;
}
.slice1 {
overflow: hidden;
/**/
position: absolute;
top: 0;
right: 0;
width: 50%;
height: 50%;
transform-origin: 0% 100%;
transform: rotate(-22.5deg) skewY(0deg);
}
.slice2 {
overflow: hidden;
/**/
position: absolute;
top: 0;
right: 0;
width: 50%;
height: 50%;
transform-origin: 0% 100%;
transform: rotate(22.5deg) skewY(0deg);
}
.slice3 {
overflow: hidden;
/**/
position: absolute;
top: 0;
right: 0;
width: 50%;
height: 50%;
transform-origin: 0% 100%;
transform: rotate(67.5deg) skewY(0deg);
}
.slice4 {
overflow: hidden;
/**/
position: absolute;
top: 0;
right: 0;
width: 50%;
height: 50%;
transform-origin: 0% 100%;
transform: rotate(112.5deg) skewY(0deg);
}
.slice5 {
overflow: hidden;
/**/
position: absolute;
top: 0;
right: 0;
width: 50%;
height: 50%;
transform-origin: 0% 100%;
transform: rotate(157.5deg) skewY(0deg);
}
.slice6 {
overflow: hidden;
/**/
position: absolute;
top: 0;
right: 0;
width: 50%;
height: 50%;
transform-origin: 0% 100%;
transform: rotate(202.5deg) skewY(0deg);
}
.slice7 {
overflow: hidden;
/**/
position: absolute;
top: 0;
right: 0;
width: 50%;
height: 50%;
transform-origin: 0% 100%;
transform: rotate(247.5deg) skewY(0deg);
}
.slice8 {
overflow: hidden;
/**/
position: absolute;
top: 0;
right: 0;
width: 50%;
height: 50%;
transform-origin: 0% 100%;
transform: rotate(-67.5deg) skewY(0deg);
}
.slice-contents1 {
position: absolute;
left: -100%;
width: 200%;
height: 200%;
border-radius: 50%;
background: #ffff4d;
text-align: center;
transition: background-color .5s;
}
.slice-contents2 {
position: absolute;
left: -100%;
width: 200%;
height: 200%;
border-radius: 50%;
background: #9AC147;
text-align: center;
transition: background-color .5s;
}
.slice-contents3 {
position: absolute;
left: -100%;
width: 200%;
height: 200%;
border-radius: 50%;
background: #639b47;
text-align: center;
transition: background-color .5s;
}
.slice-contents4 {
position: absolute;
left: -100%;
width: 200%;
height: 200%;
border-radius: 50%;
background: #3869c3;
text-align: center;
transition: background-color .5s;
}
.slice-contents5 {
position: absolute;
left: -100%;
width: 200%;
height: 200%;
border-radius: 50%;
background: #1e3868;
text-align: center;
transition: background-color .5s;
}
.slice-contents6 {
position: absolute;
left: -100%;
width: 200%;
height: 200%;
border-radius: 50%;
background: #c682bb;
text-align: center;
transition: background-color .5s;
}
.slice-contents7 {
position: absolute;
left: -100%;
width: 200%;
height: 200%;
border-radius: 50%;
background: #9a1d34;
text-align: center;
transition: background-color .5s;
}
.slice-contents8 {
position: absolute;
left: -100%;
width: 200%;
height: 200%;
border-radius: 50%;
background: #f7941e;
text-align: center;
transition: background-color .5s;
}
.slice1 .slice2 .slice3 .slice4 .slice5 .slice6 .slice7 .slice8 .slice-contents1 .slice-contents2 .slice-contents3 .slice-contents4 .slice-contents5 .slice-contents6 .slice-contents7 .slice-contents8 {
transform: skewY(40deg) rotate(25deg);
}
.slice-contents1:hover {
background: #ffff1a;
}
.slice-contents2:hover {
background: #8db23c;
}
.slice-contents3:hover {
background: #588a3f;
}
.slice-contents4:hover {
background: #2d549b;
}
.slice-contents5:hover {
background: #132340;
}
.slice-contents6:hover {
background: #ad4f9e;
}
.slice-contents7:hover {
background: #85192d;
}
.slice-contents8:hover {
background: #f38809;
}
<html>
<body>
<ul class='pie'>
<li class='slice1'>
<div class='slice-contents1'>#</div>
</li>
<li class='slice2'>
<div class='slice-contents2'>#</div>
</li>
<li class='slice3'>
<div class='slice-contents3'>#</div>
</li>
<li class='slice4'>
<div class='slice-contents4'>#</div>
</li>
<li class='slice5'>
<div class='slice-contents5'>#</div>
</li>
<li class='slice6'>
<div class='slice-contents6'>#</div>
</li>
<li class='slice7'>
<div class='slice-contents7'>#</div>
</li>
<li class='slice8'>
<div class='slice-contents8'>#</div>
</li>
<ul>
</body>
</html>