我有一张放在容器内的桌子。
我希望桌子两边都比容器宽 20 像素,但我无法让它工作。
我尝试将margin: 0 auto;table 元素更改为margin: 0 -40px;,使其在容器的每一侧悬垂20px,但这只会将整个表格向左移动。
.container {
width: 400px;
display: block;
border: 2px solid red;
margin: 0 auto;
}
table {
border-spacing: 1;
border-collapse: collapse;
background: white;
border-radius: 10px;
overflow: hidden;
width: 100%;
margin: 0 auto;
position: relative;
}
table * {
position: relative;
}
table td,
table th {
padding-left: 8px;
}
table thead tr {
height: 60px;
background: #36304a;
}
table tbody tr {
height: 50px;
}
table tbody …Run Code Online (Sandbox Code Playgroud)