鑑於這種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