The parent div sets the property of overflow-y:auto, and the box-shadow property of div cannot be displayed on the left and right sides of it.

regarding the problem of css style, the parent div sets the property of overflow-y:auto, in which the box-shadow attribute of div cannot be displayed on the left and right sides.
code is as follows:

<div id="box">
    <div class="test">    
        1975        
    </div>
</div>
-sharpbox{
    margin: 50px;
    overflow-y: auto;
}
.test{
    margin-top: 1px;
    box-shadow: 0px 0px 1px 0px rgba(0, 0, 0, 0.12), 
                0px 1px 1px 0px rgba(0, 0, 0, 0.1);
    padding: 10px;
}
Feb.27,2021

I have never encountered this problem before. I tested it and thought that the reason should be:

  1. when the overflow, overflow-y and overflow-x properties are not visible on the parent container, a container width and height calculation is triggered and the container is cropped
  2. The
  3. box-shadow attribute does not affect the width and height of the element, so it is ignored by overflow, and then cropped
  4. since the overflow, parent element is set to trigger BFC, without upper margin merging, the above box-shadow
  5. can be displayed.

in fact, the fact that overflow is not visible is very similar to the condition that triggers BFC, but it is not clear if it is the cause of BFC.

all of the above are found in chrome browsers, so you can try the above two solutions.

< H1 > but < / H1 >

however, if you are in an IE9 browser, there is no way to fully display box-shadow just by 1px's margin, or at least 2px.


set box-shadow padding


.test {
    margin: 1px 1px 2px;
    ...
}
to the parent element.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8fb9e-47036.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8fb9e-47036.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?