Sunburst effect with css3 gradient


I have been looking around and trying for a few days, but i just cant seem to get it 100% right... i am trying to achieve the following effect with css3 gradient:

sunburst done in illustrator

the closest i have gotten is DEMO:

html {
  background:
    linear-gradient(80deg, transparent 50%, #ddd 50%, #ddd),
    linear-gradient(90deg, transparent 50%, #ddd 50%, #ddd),
    linear-gradient(82deg, transparent 50%, #eee 50%, #eee),
    linear-gradient(67deg, transparent 50%, #ddd 50%, #ddd),
    linear-gradient(52deg, transparent 50%, #eee 50%, #eee),
    linear-gradient(37deg, transparent 50%, #ddd 50%, #ddd),
    linear-gradient(22deg, transparent 50%, #eee 50%, #eee),
    linear-gradient(7deg, transparent 50%, #ddd 50%, #ddd),
    linear-gradient(-8deg, transparent 50%, #eee 50%, #eee),
    linear-gradient(-23deg, transparent 50%, #ddd 50%, #ddd),
    linear-gradient(-38deg, transparent 50%, #eee 50%, #eee),
    linear-gradient(-53deg, transparent 50%, #ddd 50%, #ddd),
    linear-gradient(-68deg, transparent 50%, #eee 50%, #eee),
    linear-gradient(-83deg, transparent 50%, #ddd 50%, #ddd);
  background-position: center -100%;
  background-color: #eee;
  background-size: 100% 200%;
  min-height: 100%;
}

I will continue attempting it.. any help is greatly Appreciated though.

Update:

There has to be a better/reusable way of doing this... looking into a scss solution, here is what i have thus far:

.sunburst {
  @for $ray from 1 through 26 {
    $color: #eee;
    $degree: 7;
    @if $ray%2 == 0 {
      $color: #ddd;
    }
    background:linear-gradient($degree+deg, transparent 50%, $color 50%, $color),
  }
}

Now its just the actual maths behind it i am trying to figure out... attempting to steal logic from pow.js, but kind of difficult if your as terrible at maths as i am...


Answers:


You could use :before and :after :pseudo-elements to get this effect.

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
}
#grad {
  position: relative;
  width: 100%;
  height: 100%;
}
#grad:after, #grad:before {
  content: '';
  position: absolute;
  background: linear-gradient(90deg, transparent 50%, black 50%, black), linear-gradient(82deg, transparent 50%, #12E0DB 50%, #12E0DB), linear-gradient(67deg, transparent 50%, #000000 50%, #000000), linear-gradient(52deg, transparent 50%, #12E0DB 50%, #12E0DB), linear-gradient(37deg, transparent 50%, #000000 50%, #000000), linear-gradient(22deg, transparent 50%, #12E0DB 50%, #12E0DB), linear-gradient(7deg, transparent 50%, #000000 50%, #000000), linear-gradient(-8deg, transparent 50%, #12E0DB 50%, #12E0DB), linear-gradient(-23deg, transparent 50%, #000000 50%, #000000), linear-gradient(-38deg, transparent 50%, #12E0DB 50%, #12E0DB), linear-gradient(-53deg, transparent 50%, #000000 50%, #000000), linear-gradient(-68deg, transparent 50%, #12E0DB 50%, #12E0DB), linear-gradient(-83deg, transparent 50%, #000000 50%, #000000), linear-gradient(-90deg, transparent 50%, #12E0DB 50%, #12E0DB);
  background-position: 0% 0%;
  background-size: 200% 100%;
  height: 100%;
  width: 50%;
}
#grad:before {
  left: 50%;
  transform: rotate(180deg);
}
<div id="grad"></div>