HTML如何使表格自动展开到窗口
我对创建html表还不熟悉,我从各种资源中获取了以下信息,列出了一些测试传感器的信息 我正在努力做的是让整个表格自动展开,以填充到用户浏览器窗口的大小。目前它是一个固定宽度 要允许两列展开/调整,必须向标题中添加哪些内容 我目前的代码如下HTML如何使表格自动展开到窗口,html,html-table,Html,Html Table,我对创建html表还不熟悉,我从各种资源中获取了以下信息,列出了一些测试传感器的信息 我正在努力做的是让整个表格自动展开,以填充到用户浏览器窗口的大小。目前它是一个固定宽度 要允许两列展开/调整,必须向标题中添加哪些内容 我目前的代码如下 <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0, ma
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style type="text/css">
body {font-family: monospace; font-size: 13px; white-space: pre-wrap;}
</style>
</head>
<body>
<head> <meta http-equiv='refresh' content='30' /> </head><br/>
<style>.custom { font-size: 1em; font-family: Gill Sans Extrabold, sans-serif; padding:5px; border-collapse: collapse; border: 1px solid black; }
</style>
<table class=custom>
<tr class=custom>
<th class=custom>Security Sensor
</th>
<th class=custom>Last Tripped
</th>
</tr><br/>
<tr class=custom>
<td class=custom>20. Living Room
</td>
<td class=custom> 2018/04/09 - 11:47:52
</td>
</tr><br/>
<tr class=custom>
<td class=custom>18. Hallway
</td>
<td class=custom> 2018/04/09 - 11:47:17
</td>
</tr><br/>
<tr class=custom>
<td class=custom>10. Kitchen
</td>
<td class=custom> 2018/04/09 - 11:47:17
</td>
</tr><br/>
<tr class=custom>
<td class=custom>Kitchen - Motion Sensor
</td>
<td class=custom> 2018/04/09 - 11:39:41
</td>
</tr><br/>
<tr class=custom>
<td class=custom>17. Entrance Hall
</td>
<td class=custom> 2018/04/09 - 11:13:42
</td>
</tr><br/>lt;tr class=custom>
<td class=custom>05. Ben's Room
</td><td class=custom> 2018/04/09 - 11:13:26
</td>
</tr><br/>
<tr class=custom>
<td class=custom>02. Landing
</td>
<td class=custom> 2018/04/09 - 11:13:22
</td>
</tr><br/>
<tr class=custom>
<td class=custom>03. Loft Landing
</td>
<td class=custom> 2018/04/09 - 11:13:21
</td>
</tr><br/>
<tr class=custom>
<td class=custom>06. Loft Room
</td>
<td class=custom> 2018/04/09 - 11:13:14
</td>
</tr><br/>
<tr class=custom>
<td class=custom>01. Front Door
</td>
<td class=custom> 2018/04/09 - 10:38:47
</td>
</tr><br/>
<tr class=custom>
<td class=custom>08. Side Door
</td>
<td class=custom> 2018/04/09 - 10:36:04
</td>
</tr><br/>
<tr class=custom>
<td class=custom>13. Conservatory
</td>
<td class=custom> 2018/04/09 - 10:35:47
</td>
</tr><br/>
<tr class=custom>
<td class=custom>19. Front Room
</td>
<td class=custom> 2018/04/09 - 10:35:15
</td>
</tr><br/>
<tr class=custom>
<td class=custom>12. Dining Room
</td>
<td class=custom> 2018/04/09 - 10:34:36
</td>
</tr><br/>
<tr class=custom>
<td class=custom>07. Conservatory Door
</td>
<td class=custom> 2018/04/09 - 10:32:13
</td>
</tr><br/>
<tr class=custom>
<td class=custom>04. Main Bedroom
</td>
<td class=custom> 2018/04/09 - 10:23:57
</td>
</tr><br/>
<tr class=custom>
<td class=custom>09. Emma's Room</td>
<td class=custom> 2018/04/09 - 09:31:53
</td>
</tr><br/>
<tr class=custom>
<td class=custom>14. Kitchen Door
</td>
<td class=custom> 2018/04/08 - 16:21:20
</td>
</tr><br/>
<tr class=custom>
<td class=custom>11. Lean To</td>
<td class=custom> 2017/12/16 - 12:20:04
</td>
</tr><br/>
</table><br/>
</body>
</html>
在类中或直接在表标记中指定宽度。您还可以在td标记中为表列指定宽度
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style type="text/css">
body {
font-family: monospace;
font-size: 13px;
white-space: pre-wrap;
}
.custom { font-size: 1em; font-family: Gill Sans Extrabold, sans-serif; padding:5px; border-collapse: collapse; border: 1px solid black; } table { width:100% } .th { width:50% }
</style>
</head>
<body>
<table class=custom>
<tr class=custom>
<th class=custom>Security Sensor</th>
<th class=custom>Last Tripped</th>
</tr>
<br/>
<tr class=custom>
<td class=custom>20. Living Room</td>
<td class=custom> 2018/04/09 - 11:47:52</td>
</tr>
<br/>
<tr class=custom>
<td class=custom>18. Hallway</td>
<td class=custom> 2018/04/09 - 11:47:17</td>
</tr>
<br/>
<tr class=custom>
<td class=custom>10. Kitchen</td>
<td class=custom> 2018/04/09 - 11:47:17</td>
</tr>
<br/>
<tr class=custom>
<td class=custom>Kitchen - Motion Sensor</td>
<td class=custom> 2018/04/09 - 11:39:41</td>
</tr>
<br/>
<tr class=custom>
<td class=custom>17. Entrance Hall</td>
<td class=custom> 2018/04/09 - 11:13:42</td>
</tr>
<br/>
<tr class=custom>
<td class=custom>05. Ben's Room</td>
<td class=custom> 2018/04/09 - 11:13:26</td>
</tr>
<br/>
<tr class=custom>
<td class=custom>02. Landing</td>
<td class=custom> 2018/04/09 - 11:13:22</td>
</tr>
<br/>
<tr class=custom>
<td class=custom>03. Loft Landing</td>
<td class=custom> 2018/04/09 - 11:13:21</td>
</tr>
<br/>
<tr class=custom>
<td class=custom>06. Loft Room</td>
<td class=custom> 2018/04/09 - 11:13:14</td>
</tr>
<br/>
<tr class=custom>
<td class=custom>01. Front Door</td>
<td class=custom> 2018/04/09 - 10:38:47</td>
</tr>
<br/>
<tr class=custom>
<td class=custom>08. Side Door</td>
<td class=custom> 2018/04/09 - 10:36:04</td>
</tr>
<br/>
<tr class=custom>
<td class=custom>13. Conservatory</td>
<td class=custom> 2018/04/09 - 10:35:47</td>
</tr>
<br/>
<tr class=custom>
<td class=custom>19. Front Room</td>
<td class=custom> 2018/04/09 - 10:35:15</td>
</tr>
<br/>
<tr class=custom>
<td class=custom>12. Dining Room</td>
<td class=custom> 2018/04/09 - 10:34:36</td>
</tr>
<br/>
</table>
</body>
</html>
这将起到必要的作用:
工作台宽度=100%?使用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title></title>
<style type='text/css'>
table {
border: thin solid black;
width: auto;
height: auto;
}
</style>
</head>
<body>
<table>
<tr>
<td>
The table only expands enough for the content inside of it.
</td>
</tr>
</table>
</body>
</html>