我想創建一個使用html的完整頁面日曆,其行爲與您認爲的一樣。它盡最大努力在一個屏幕上顯示整個月份。任何不符合表格單元的文本 都會導致當天出現一個小滾動條。使用CSS定位數字的HTML表格日曆
我迄今爲止的代碼在Chrome中表現得相當不錯,只不過日期數字往往會在前一週被壓縮。
在Firefox它忽略了表格單元格的溢出設置,所以表細胞失去滾動條。
(不與IE有關我自己)
我的問題是:我如何才能讓數字來表現自己。如果Firefox能夠以同樣的方式呈現,那將是一種獎勵。
這裏的CSS:
/* for looking at the outlines of things */
* {
border:1px dashed #0000FF;
}
.scrollable_table {
width: 100%;
height: 100%;
/*overflow: auto;*/
}
.calendar_num {
position:relative;
display: inline-block;
float:right;
margin-top:1px;
}
.calendar_row {
width:100%;
}
.calendar_td {
width:14%;
/*height:14%; */
}
.scrollable_td {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: auto;
}
下面是一個 '典型的' 月一些示例代碼:
<html><head>
<link type='text/css' rel='stylesheet' href='/static/calendar.css' />
<body>
<table class=scrollable_table>
<tr class=calendar_row>
<td class=calendar_td></td>
<td class=calendar_td></td>
<td class=calendar_td></td>
<td class=calendar_td></td>
<td class=calendar_td></td>
<td class=calendar_td></td>
<td class=calendar_td>
<div class=calendar_num>1</div>
<div class=scrollable_td>day: 1
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
</tr>
<tr class=calendar_row>
<td class=calendar_td>
<div class=calendar_num>2</div>
<div class=scrollable_td>day: 2
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>3</div>
<div class=scrollable_td>day: 3
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>4</div>
<div class=scrollable_td>day: 4
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>5</div>
<div class=scrollable_td>day: 5
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>6</div>
<div class=scrollable_td>day: 6
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>7</div>
<div class=scrollable_td>day: 7
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>8</div>
<div class=scrollable_td>day: 8
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
</tr>
<tr class=calendar_row>
<td class=calendar_td>
<div class=calendar_num>9</div>
<div class=scrollable_td>day: 9
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>10</div>
<div class=scrollable_td>day: 10
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>11</div>
<div class=scrollable_td>day: 11
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>12</div>
<div class=scrollable_td>day: 12
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>13</div>
<div class=scrollable_td>day: 13
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>14</div>
<div class=scrollable_td>day: 14
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>15</div>
<div class=scrollable_td>day: 15
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
</tr>
<tr class=calendar_row>
<td class=calendar_td>
<div class=calendar_num>16</div>
<div class=scrollable_td>day: 16
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>17</div>
<div class=scrollable_td>day: 17
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>18</div>
<div class=scrollable_td>day: 18
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>19</div>
<div class=scrollable_td>day: 19
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>20</div>
<div class=scrollable_td>day: 20
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>21</div>
<div class=scrollable_td>day: 21
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>22</div>
<div class=scrollable_td>day: 22
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
</tr>
<tr class=calendar_row>
<td class=calendar_td>
<div class=calendar_num>23</div>
<div class=scrollable_td>day: 23
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>24</div>
<div class=scrollable_td>day: 24
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>25</div>
<div class=scrollable_td>day: 25
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>26</div>
<div class=scrollable_td>day: 26
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>27</div>
<div class=scrollable_td>day: 27
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>28</div>
<div class=scrollable_td>day: 28
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>29</div>
<div class=scrollable_td>day: 29
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
</tr>
<tr class=calendar_row>
<td class=calendar_td>
<div class=calendar_num>30</div>
<div class=scrollable_td>day: 30
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td>
<div class=calendar_num>31</div>
<div class=scrollable_td>day: 31
<br/>a bunch of text that could flow off the end of the td. a bunch of text that could flow off the end of the td. a bunch of text that could flow o
</td>
<td class=calendar_td></td>
<td class=calendar_td></td>
<td class=calendar_td></td>
<td class=calendar_td></td>
<td class=calendar_td></td>
</tr>
</table>
</body>
</html>
這裏是一個小提琴calendar fiddle
T他的一個也是在firefox烤麪包 – slashdottir
只是試了一遍,它在firefox中工作就好了。我認爲這是新的答案。 – slashdottir
雖然我同意這個新的答案。我想指出[有近18年的錯誤](https://bugzilla.mozilla.org/show_bug.cgi?id=35168),它阻止了在表格中使用位置絕對元素。這個bug已經解決了,因此這是今天的正確答案。 –