Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.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_Html Table - Fatal编程技术网

如何在html表中设置相同的列?

如何在html表中设置相同的列?,html,html-table,Html,Html Table,我试图使相同的列大小表…但如果内容超过列大小自动增加…为什么会这样 这是我的html代码: <!DOCTYPE html> <html> <head> <style> table { background-color: #eaeaea; width : 80%; border: 1px solid ; } td { width

我试图使相同的列大小表…但如果内容超过列大小自动增加…为什么会这样

这是我的html代码:

    <!DOCTYPE html>
    <html>
    <head>
    <style>
   table {
        background-color: #eaeaea;
        width : 80%;
        border: 1px solid ; 
    }
     td {

        width : 20%;
        border: 1px solid ; 
    }
    </style>
    </head>
    <body>
   <table>
    <tr>
        <td>Alfreds hrtfjfgjkfgAlfreds hrtfjfgjkfgAlfreds hrtfjfgjkfgAlfreds hrtfjfgjkfgAlfreds </td>
        <td>Maria Anders</td>
        <td>Germany</td>
        <td>GermanyGermanyGermanyGermanyGermanyGermany</td>
      </tr>
      <tr>
        <td>Alfreds Futterkiste</td>
        <td>Maria Anders</td>
        <td></td>
        <td></td>
      </tr>
</table>
 </body>
  </html>

桌子{
背景色:#eaeaea;
宽度:80%;
边框:1px实心;
}
运输署{
宽度:20%;
边框:1px实心;
}
阿尔弗雷德hrtfjfgjkfgf阿尔弗雷德hrtfjfgjkfgf阿尔弗雷德hrtfjfgjkfgf阿尔弗雷德hrtfjfgjkfgf阿尔弗雷德
玛丽亚·安德斯
德国
德国德国德国德国
阿尔弗雷德·福特基斯特
玛丽亚·安德斯
这是我的订单:


添加表格布局:固定到表格,将换行符添加到单元格

就像这样:

table {
    background-color: #eaeaea;
    width : 80%;
    border: 1px solid ; 
    table-layout: fixed;
}
 td {

    width : 20%;
    border: 1px solid ; 
    word-wrap: break-word;
}

尝试最大宽度:20%;和最小宽度:20%在你的css中。我试过了,但仍然有同样的问题,所以我已经有很长一段时间没有接触HTML了,但你想要实现的是相当复杂的。检查这把小提琴。即使你设定一个固定的宽度,他也会走火入魔。表需要是动态的,老实说,不会有那么大的词,因为问题是HTML本身不会分解大词(就像我们使用-)编写时那样)。检查此链接可能会帮助您:)是的,我可以理解word不会那么大,但是有一个链接代替了word,因此列大小会增加…即使word很小,列大小也会减少。