here is my html/css code:
<style>
td{
padding:30px;
box-shadow: 0 0 5px 5px lightgray;
}
</style>
<table>
<tr>
<td>1</td><td>2</td>
</tr>
<tr>
<td>3</td>
</tr>
</table>
this produces the the folowing output
my question is: is there a way to make the box-shadow not affect the adjacent td?
here is the required output:
2
Answers
Consider using
filter: drop-shadow
on thetable
element. This way all solid child elements are treated as a whole to make a single instance of a shadow.But be aware it doesn’t support
spread
option likebox-shadow
does, to achieve heavier shadows, you might want to add more shadow instances to the filter:@HaoWu’s answer is excellent. Here is another approach.
Apply the box shadow to a pseudo-element and have a same stacking context for all
td
s so that you can push all the pseudo element behind alltd
s.