Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
HTML宽度属性在标记中不起作用_Html_Markdown - Fatal编程技术网

HTML宽度属性在标记中不起作用

HTML宽度属性在标记中不起作用,html,markdown,Html,Markdown,我在Markdown中使用HTML创建一个表 代码是 <table> <thead> <tr> <th style="width:2px;text-align: center;background: #2c3e50;" ><font face="youyuan">Column1</font></th> <th style="width:150px; text

我在Markdown中使用HTML创建一个表

代码是

<table>
<thead>
<tr>
<th style="width:2px;text-align: center;background: #2c3e50;" ><font face="youyuan">Column1</font></th>
<th style="width:150px; text-align: center;background: #c3e50;"  ><font face="youyuan">Column2</font></th>
<th style="text-align: center;background: #2c3e50;"  ><font face="youyuan";>Column3</font></th>
</tr>
</thead>

<tbody>
...
</tbody>

</table>

专栏1
专栏2
第3栏
...

其他参数如
background
text align
工作正常。但是,列长度根本不会改变。三列相等地分开。为什么
宽度在这里不起作用,以及如何解决这个问题?

默认情况下,表格单元格没有带滚动功能的溢出。因此,默认行为将导致单元格相应地调整大小,以允许内容实际适合单元格。如果删除内容
Column1
,则会看到单元格的宽度仅为声明的2px。如果没有内容,单元格将不会溢出,因此大小可能为2px


专栏2
第3栏
...

因为内容太宽,单元格会溢出。因此,它将被忽略并调整大小以允许内容适合单元格。如果您真的想将列的宽度限制为2px,请使用
max width
.Hi@tacoshy谢谢您的回复~。它是20px,我只是想测试一下它是否有效。。。但是,我将所有
宽度
修改为
最大宽度
,但仍然没有任何更改。检查背景颜色的大小,它只是溢出单元格,然后将设计完全弄乱。要使内容适合20px,您需要声明一个分词(wordwrap),以便内容更小。表格有其局限性,这也是它们不应用于设计目的的原因。