Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
964 views
in Technique[技术] by (71.8m points)

css - 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%;
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...