简体   繁体   English

在HTML中为一栏设置th或td高度

[英]Set th or td height in HTML for one column

I'm trying to set the <th> size for one column. 我正在尝试为一栏设置<th>大小。 I was trying something like 我在尝试类似

<th width=100> Description </th>

and the same for <tr> ( <tr width=100> ) <tr>相同( <tr width=100>

The above does not resize the column at all. 上面根本没有调整列的大小。

You are attempting to use an inline style inside your HTML tags. 您正在尝试在HTML标记内使用内联样式。 First off, I recommend quotes around your units of measure like so. 首先,我建议像这样在您的计量单位周围加引号。 <th width="100"></th> Also, you arent defining the units of measure of the tags. <th width="100"></th>另外,您也无法定义标签的度量单位。 you can use: <th width="100px"></th> or <th width="100%"></th> i think that you can even do inches and centimeters. 您可以使用: <th width="100px"></th><th width="100%"></th>我认为您甚至可以做到英寸和厘米。 Be careful when using the inline style `length' as the webpage is limitless.... 使用内联样式“ length”时要小心,因为网页是无限的。

Another way you can do this is using CSS. 您可以执行此操作的另一种方法是使用CSS。 Inside your head tag could be a <style> tag. 您的head标签内可能是<style>标签。 Inside you can do: .measure { width:100px; } 在内部可以执行以下操作: .measure { width:100px; } .measure { width:100px; } Note it doesn't have to be pixels. .measure { width:100px; }请注意,它不一定是像素。 Then on any tag you want 100px wide, you just do: <th class="width"></th> or <tr class="measure"></tr> . 然后,在您想要100px宽的任何标签上,只需执行: <th class="width"></th><tr class="measure"></tr> Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM