我建立一個網站,我需要的佈局是這樣的:CSS自動展開寬度爲表
+---+--------------+
|# | |
|n | #page |
|a | table.basic |
|i | |
|g | |
|a | |
|t | |
|i | |
|o +--------------+
|n | #pagination |
+---+--------------+
下面是HTML CSS &:
#navigation {
float: left;
width: 150px; /* Fixed size*/
min-height: 100%;
margin: 0;
padding: 0 2em;
}
#page {
float: left;
width: auto; /* Auto size. Something need to be changed here.*/
padding-left: 2em;
vertical-align: top;
}
#pagination {
font-size: 1.3em;
position: relative;
clear: both;
padding: 0.5em;
text-align: center;
}
table.basic tr th,
table.basic tr td {
/* or change something here*/
border: 2px solid #000000;
font-weight: bold;
margin: 1em 0;
padding: 1em;
}
<div id="navigation">Show navigation</div>
<div id="page">
<table class="basic">
<tr>
<th>id</th>
<th>text</th>
</tr>
<tr>
<td>1</td>
<td>Long long thing</td>
</tr>
</table>
<div id="pagination">Show pagination</div>
</div>
帶表格的頁面內容需要自動展開,因此它不會在導航欄下浮動。任何想法?
你嘗試'寬度:理論值(100% - 150像素)'?或'calc(100% - 150px - 2em - 2em)'? – Quantastical
介意正確寫出你的CSS評論(我已編輯它:) :) –