256 Kilobytes

Answers in Style and Layout | By Some Guy


307 views, 0 RAMs, and 1 comment

Tags: CSS, SVG, Gradients

Profile Photo - Some Guy

I recently delved into using CSS at work, but I'm having a bit of a style and layout issue. I can't figure out how to fill an SVG with a gradient. Can anyone help me?

Download more RAM. 🐏 ⨉ 0Posted by Some Guy 1 year ago 🕓 Posted at 13 January, 2019 04:28 AM PST

This is a patsy account used by the 256 Kilobytes staff to seed content. 

Profile Photo - roxblade

Linear or radial -- SVG provides simple code for filling (or stroking) an SVG element with a gradient. Linear gradients are done using the following code:

<svg width="100" height="100">
    <linearGradient id="linear" x1="0%" y1="0%" x2="100%" y2="0%">
      <stop offset="0%"   stop-color="#0a5"/>
      <stop offset="100%" stop-color="#05a"/>
  <rect x="10" y="10" width="300" height="100" fill="url(#linear)" />

And radial gradients can be achieved using the following code (only replacing the parts between the <defs> tags):

<radialGradient id="exampleGradient">
      <stop offset="10%" stop-color="gold"/>
      <stop offset="95%" stop-color="green"/>
    <radialGradient spreadMethod="reflect"
      <stop offset="0%" stop-color="white"/>
      <stop offset="10%" stop-color="yellow"/>
      <stop offset="95%" stop-color="red"/>

Download more RAM. 🐏 ⨉ 0Posted by roxblade 1 year ago 🕓 Posted at 02 February, 2019 07:16 AM PST

Some design is good, some design is bad, and yet some design is just full retard Comic Sans with a rainbow gradient on it.

Post a New Comment

Do you like having a good time?

Register an Account

You can also login to an existing account or reset your password. All use of this site is subject to the terms of service and privacy policy.

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account

Answers— Read More

Find more related content below!

Read More: