Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render multiple shadows on one element?

For example, how to accomplish

box-shadow: 2px 2px 4px rgba(0, 0, 0, .05), -2px -2px 4px rgba(0, 0, 0, .05);

in react native stylesheet?

like image 931
tga Avatar asked May 03 '16 07:05

tga


People also ask

How do you make multiple shadows?

Multiple shadows can be made using the same code that is used for making single shadow. To make these multiple shadows we just need to define multiple shadow value and seperate them with a comma. Then we'll position the shadows using different values for x-offset and y-offset values.

Can you specify more than one box shadow to an element?

Box shadows can use commas to have multiple effects, just like with background images (in CSS3). While you can apply multiple shadows, applying inset shadows, I've found, is a special case.

How do I make more than one shadow in CSS?

To add more than one shadow to the text, you can add a comma-separated list of shadows.

How do you add shadow to elements?

In CSS, shadows on the boxes of elements are created using the box-shadow property (if you want to add a shadow to the text itself, you need text-shadow ). The box-shadow property takes a number of values: The offset on the x-axis. The offset on the y-axis.


1 Answers

I don't think you can, but the hack of wrapping your component with another just for another layer of shadow is the worst hack of the century either:

<div style={{ boxShadow: "2px 2px 4px rgba(0, 0, 0, .05)"}}>
  <div style={{ boxShadow: "-2px -2px 4px rgba(0, 0, 0, .05)"}}>
  { content }
  </div>
</div>
like image 132
Sitian Liu Avatar answered Nov 11 '22 04:11

Sitian Liu