I have two blocks. Let’s imagine it’s not possible to set one box-shadow for parents of these two blocks. I need to set box-shadow for each blocks, and it must look as if I set it to parent.
body {
padding: 50px;
}
.block1 {
padding: 20px;
border-width: 1px 1px 0 1px;
border-style: solid;
border-radius: 4px 4px 0 0;
border-color: #d5dce3;
box-shadow: 0 0 2px #00000017,0 5px 25px #0000000a,0 1px 5px #040b170a;
}
.block2 {
padding: 20px;
border-width: 0 1px 1px 1px;
border-style: solid;
border-radius: 0 0 4px 4px;
border-color: #d5dce3;
box-shadow: 0 0 2px #00000017,0 5px 25px #0000000a,0 1px 5px #040b170a;
}
<div class="block1">
Block 1
</div>
<div class="block2">
Block 2
</div>
3
Answers
I just modified your snippet here so you can just give it a try.
It’s indeed better using an outer
div
to wrap the blocks…Use
clip-path
to remove the bottom/top shadow from.block1
/.block2
like this:It’s a special situation, so try this.
As the number of blocks increases, the height can be adjusted.