Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a radial css3 border gradient shadow

I have two columns that can stretch to variable heights, the designer wants to have a shadow between the two columns, but as you can see the image fades out at the top and the bottom. That means I can't just use a background image using css that is left aligned in the column on the right.

Columns with a radial shadow in between

So then I though maybe I can use a css 3 border shadow that has a radial gradient. I am probably going to use table cells to do this because I need the shadow to stretch to the height of the tallest column. How do I do this?

like image 340
superlogical Avatar asked Oct 30 '12 07:10

superlogical


People also ask

How do you put a gradient shadow in CSS?

Now, if we want to add a gradient-y box shadow behind this box, we can do it using a ::before pseudo-element around it and makes it looks like a shadow. As you can tell, since we want a gradient shadow, we're using linear-gradient as the background of the pseudo-element.

How do you add a radial gradient in CSS?

The radial-gradient() function sets a radial gradient as the background image. A radial gradient is defined by its center. To create a radial gradient you must define at least two color stops.

How do you put a gradient border radius in CSS?

To show gradients for a border with CSS you can use the border-image property. It allows setting gradient values in the same way as the background-image property. Besides the border-image property, you should specify additional properties to actually show border gradient.


1 Answers

Previous answers doesn't really answer your question: "How do I create a radial css3 border gradient shadow"

You can use a radial gradient to simulate a border shadow without images.

Demo: http://jsfiddle.net/sonic1980/wRuaZ/

enter image description here

background: -webkit-radial-gradient(50% 0%, 50% 5px, #aaa 0%, white 100%);
                                    |       |        |        |
                                    |       |        |        +--> color end     
                                    |       |        +--> color start
                                    |       +--> size of gradient ellipse (x-axis, y-axis)
                                    +---> position of ellipse center

It's easy to modify to make it vertical or implement using :before or :after pseudo-classes.

Another example, an <hr> tag with shadow: http://jsfiddle.net/sonic1980/65Hfc/

like image 85
Peter Avatar answered Jan 21 '23 12:01

Peter