[英]CSS box model width
<div style="width:500px;">
<p>To create not a block, but an inline code span,use backticks:Press the `<Tab>` key, then type a `$`.If you want to have a preformatted block within a list, indent by eight spaces: </p>
<table>
<thead>
<tr><th>Action</th>
<th>abc</th>
<th>xyz</th>
</tr>
</thead>
<tbody>
<tr><td>hihi</td>
<td>hihi</td>
</tr>
</tbody>
</table>
I set the div of width 500px, and under it I have p
and table
elemetns. 我将宽度的div设置为500px,在其下有
p
和table
elemetns。 The p
element adjust to the width of the div, while the table has its own width, which doesnt necessarily adjust to fit into 500px. p
元素调整为div的宽度,而表格具有其自身的宽度,不一定调整为适合500px。 I don't know how this works, can anyone explain it to me? 我不知道这是如何工作的,有人可以向我解释吗? Thanks
谢谢
By default, <table>
elements adjust to auto fit their contents. 默认情况下,
<table>
元素会进行调整以自动适应其内容。 If the contents don't need the full container, the space isnt taken. 如果内容不需要完整的容器,则不占用空间。 You can change this behavior by styling the table with:
您可以通过使用以下样式设置表的样式来更改此行为:
<table style="width: 100%;">
In which case it will take all available width if possible. 在这种情况下,将尽可能占用所有可用宽度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.