我发现如果你调整 div 的大小,阴影会保持在原来的位置。我单击按钮使子 div 更改高度,并且父级也更改高度,但阴影没有删除。
<script type="text/javascript">
$(function () {
// change width
$('#btn1').toggle(function () {
$('#div1').height(100);
},
function () {
$('#div1').height(200);
});
});
</script>
<style type="text/css">
#div1
{
height: 200px;
}
#div2
{
width: 200px;
box-shadow: 2px 2px 8px #000000;
position: absolute;
left: 200px;
top: 200px;
}
</style>
<body>
<div id="div2">
<div id="div1">
<input type="button" id="btn1" value="test" />
</div>
</div>