全寬所以,我有一個表:HTML表保證金
<table border=1>
<caption>This is a table.</caption>
<tr>
<th>One</th>
<th>Two</th>
<th>Three</th>
</tr>
<tr>
<td>Four</td>
<td>Five</td>
<td>Six</td>
</tr>
</table>
,我希望它是儘可能寬,同時仍然留在每邊20像素的保證金。所以,我這樣做:
table{
border-collapse:collapse;
margin:20px;
padding:0;
width:100%;
}
,但它最終被父的寬度,再加上左側有一個額外20px的保證金,造成垂直滾動條出現。有沒有辦法使它的40px比父寬度小,而不需要添加其他元素來包圍它呢?
的jsfiddle:http://jsfiddle.net/pvHNM/
的[股利寬度的像素的100%減去固定量]可能重複(http://stackoverflow.com/questions/651317/div-width-100-minus-fixed-amount-of-pixels) – Gajus 2014-04-06 13:15:26