html - 如何更改此 html 表格的列宽

标签 html css html-table

这里有指定列宽的方法吗?

您好,我正在尝试设置表格样式,但我不知道如何指定列宽。我读到过使用 CSS 的方法:<td style="width:130px">

我正在使用 xampp,而且我只使用了一个 PHP 文件。

<!DOCTYPE html>
<html>

<body>

  <table>
    <tr>
      <td>$item</td>
      <td><img src='item_image_folder/img'></td>
    </tr>
  </table>

</body>

</html>

表格的样子

Category 1

item_name  image
item_name  image

Category 2

item   image 
item   image 

Category 3

long_item_name   image 

最佳答案

<style>
td {
   width:130px;
}
</style>

这是使用 css样式,指定 <td> 的宽度的

关于html - 如何更改此 html 表格的列宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50901920/

相关文章:

html - 表格剥离为特殊 tr 设置相同的背景颜色

javascript - 切换可变数量的表行

html - 如何拉伸(stretch)DIV内的背景图片

html - 每个列表项后带有外部图标的 Bootstrap 链接列表

html - 我的行内 block 元素没有正确排列

css - 为什么图像链接在 Chrome/Firefox 中有效,但在 Internet Explorer 中无效?

javascript - 更改内容可编辑的 div 中某些字符的字体大小

css - img 嵌套在 div CSS 中

javascript - Canvas 显示奇怪

javascript - 如何收集动态添加的行(HTML 表格)的值(数据)?使用 php 和 XAMPP