Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a radial gradients radius 200px

How would I make the radius 200px in width and height? I've read that this can be done in pixel units, but every attempt has failed.

background-image: -webkit-radial-gradient(75% 100%, circle farthest-corner, #ffffff, #ff7ae9 33%);
background-image: -o-radial-gradient(75% 19%, circle farthest-corner, #ffffff, #ff7ae9 33%);
background-image: -ms-radial-gradient(75% 19%, circle farthest-corner, #ffffff, #ff7ae9 33%);
background-image: radial-gradient(75% 19%, circle farthest-corner, #ffffff, #ff7ae9 33%)
background-image: -moz-radial-gradient(75% 19%, circle farthest-corner, #ffffff, #ff7ae9 33%);
like image 866
android.nick Avatar asked Sep 21 '11 05:09

android.nick


People also ask

How do you make a radial gradient in Photoshop?

Select the Radial Gradient tool by clicking its icon in the column on the right or pressing the R key. Drag over the area that you want to adjust. The point where you start to drag will become the center of the radial gradient. Drag the sliders in the Radial Gradient panel to make your adjustments.

How do you make a radial gradient in html5 canvas?

The createRadialGradient() method creates a radial/circular gradient object. The gradient can be used to fill rectangles, circles, lines, text, etc. Tip: Use this object as the value to the strokeStyle or fillStyle properties.

How do you add a gradient to a circle in CSS?

radial-gradient() The radial-gradient() CSS function creates an image consisting of a progressive transition between two or more colors that radiate from an origin. Its shape may be a circle or an ellipse. The function's result is an object of the <gradient> data type, which is a special kind of <image> .


1 Answers

edit: added all the vendor prefixes to make it clearer


background-image:    -moz-radial-gradient(50px 100px, circle farthest-corner, #ffffff, #ff7ae9 200px);
background-image: -webkit-radial-gradient(50px 100px, circle farthest-corner, #ffffff, #ff7ae9 200px);
background-image:      -o-radial-gradient(50px 100px, circle farthest-corner, #ffffff, #ff7ae9 200px);
background-image:     -ms-radial-gradient(50px 100px, circle farthest-corner, #ffffff, #ff7ae9 200px);
background-image:         radial-gradient(50px 100px, circle farthest-corner, #ffffff, #ff7ae9 200px);

In this example the '200px' is the size of the circle, any standard CSS units such as px, em or percentages are fine.

The '50px 100px' is the position of the centre of the circle, it works the same way as background-position so values like 'left top' are fine too.

There are a few online generators that can help you with all the vendor specific prefixes.


p.s.
@Mohsen pixel values are fine, MDN says:

either a percentage between 0% and 100% or a length along the gradient axis

If you click on 'length' it says

The CSS syntax for length is a number followed immediately by a unit. Space between the number and the unit is not allowed.

like image 86
Jedidiah Avatar answered Sep 18 '22 13:09

Jedidiah