鉴于这种HTML和CSS代码:CSS表单元格边距弄乱
header,
footer {
text-align: center;
background: #fafafa;
padding: 20px 0;
}
.wrapper {
display: table;
width: 1024px;
background: blue;
margin: 0px auto;
}
section {
width: 50%;
display: table-cell;
background: #e5e5e5;
/* This line is the root of the problem */
padding: 20px;
}
aside {
width: 50%;
display: table-cell;
background: #c5c5c5;
}
<header>header</header>
<div id="main">
<div class="wrapper">
<section>left<br />left<br />left<br />left<br />left<br /></section>
<aside>right<br />right<br />right<br />right<br />right<br /></aside>
</div>
</div>
<footer>footer</footer>
我有一个问题,当我section
元素(左元素)上添加填充。 它还在aside
元素(正确元素)上添加了一些填充顶部,我不想要这些元素。
这里是没有填充的截图:
这里与左元素的填充截图:
如何摆脱任何线索在右边的元素上自动添加填充?
在此先感谢
其实,我只是想左元素得到填充。不是正确的。 – SmartyLisp
如果“在表格中,行中的每个单元格都具有相同的样式”,为什么右侧元素在其内容的左侧没有填充?像其他细胞一样,事实上呢? – SmartyLisp
请参阅编辑答案,我的意思是“同样的风格”在这里是相同的高度。 – Kramer