【发布时间】:2018-06-09 23:23:39
【问题描述】:
我已将一个<div> 放置在另一个具有绝对位置且左边距为 10 像素(这是因为我想显示阴影)的位置上。
问题是基础<div>的内容显示在标题<div>的左侧,如何避免这种情况?如果我使用border-left而不是padding-left,则不会显示阴影。
#container {
background-color: green;
display: flex;
}
.item {
background-color: white;
border: 1px solid black;
flex-grow: 0;
}
.bigContent{
height: 1000px;
width: 1000px;
}
.scroll{
overflow: auto;
height: 300px;
width: 500px;
}
.header{
height: 280px;
width: 200px;
position: absolute;
z-index: 1;
padding-left:10px;
overflow:hidden;
display: inline;
border: solid 1px;
}
.headerContent{
background: lightgrey;
height: 280px;
width: 200px;
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}
<div id="container">
<div id="header" class="header">
<div class="headerContent">
<div class="shadow">
<table width="500px">
<tr><td>Header</td></tr>
</table>
</div>
</div>
</div>
<div class="item scroll">
<div class="bigContent">
<table width="500px">
<tr><td>Some content</td><td>Some content</td><td>Some content</td><td>Some content</td><td>Some content</td><td>Some content</td></tr>
</table>
</div>
</div>
</div>
【问题讨论】:
-
添加 .header {background-color: white);
标签: css css-position padding absolute