oneandonlycore
oneandonlycore

Reputation: 480

CSS radial gradient to SVG radial gradient

is it possible to make an radial gradient in SVG like it is here in CSS http://codepen.io/A973C/pen/hnEaf (i mean the lights in the trafficlight)

.red{
  background: red;
  background-image: radial-gradient(brown, transparent);
  background-size: 15px 15px; 
  width: 100px;
  height: 100px;
  border-radius: 50%;
  position: absolute;
  top: 20px;
  left: 35px;
  animation: 13s red infinite;
  border: dotted 2px red;
  box-shadow: 
    0 0 20px #111 inset,
    0 0 10px red;
}

my SVG gradient looks like this http://jsfiddle.net/x9a2Lyx1/ I dont really understand how i can repeat the gradient like its in the css example

Upvotes: 1

Views: 2314

Answers (2)

Chris Spittles
Chris Spittles

Reputation: 15359

An SVG element embedded in a webpage is treated the same as any other element so you could just use CSS to do it:

svg {
  background: green;
  background-image: radial-gradient(lime, transparent);
  background-size: 3px 3px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: dotted 2px lime;
  box-shadow: 
    0 0 20px #111 inset,
    0 0 10px lime;
}
<svg width="120" height="120" 
     xmlns="http://www.w3.org/2000/svg" version="1.1"
     xmlns:xlink="http://www.w3.org/1999/xlink">       
</svg>

Upvotes: 1

oneandonlycore
oneandonlycore

Reputation: 480

ive solved this using SVG Pattern -> http://jsfiddle.net/k5527kym/

<pattern id="muster_c" patternUnits="userSpaceOnUse" width="2" height="2" x="0" y="0">
        <circle cx="1" cy="1" r="2" fill="url(#MyGradient)"/>
</pattern>

Upvotes: 1

Related Questions