Box Shadow
In a page layout, whether it’s a normal document flow or a Flex layout, the page is filled with boxes. Box-shadow is an indispensable effect in page design. In a single box element, the box-shadow will be projected onto the parent. But when the shadow box is pressed against it, the shadow becomes invisible.
Method 1
In need ofbox-shadow
Element Settings ofposition: relative
In normal document flow, close means that the element’s shadow on the parent is overwritten by the next element, so setting position: relative takes the element out of the document flow, and the browser handles it alone, resulting in a stack on the Z-axis, where there is no close, and the shadow is projected directly onto the normal document flow.
Method 2
Set on the parentflex
And then in needshadow
Element Settings ofz-index
Greater than or equal to 0
Flex changes the direct child element to a flex-item element, at which point it is no longer a document flow. Flex-item has the concept of the Z-axis, so setting the Z-index adjusts the stack level at which the shadows appear.
attribute
- position
- z-index
- flex
knowledge
- The document flow
- The stack
- positioning