Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.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_Twitter Bootstrap - Fatal编程技术网

html:设置列宽

html:设置列宽,html,twitter-bootstrap,Html,Twitter Bootstrap,我想为我的每一列设置一个自定义。但是由于一个未知的原因,例如,如果我增加第3列的大小,第2列的大小就会减小。 有人知道为什么会有这种行为吗 <table class="table" style="table-layout: fixed;width:1165px"> <thead> <th style="width:137px">Col 1</th> <th style="width:137px">

我想为我的每一列设置一个自定义。但是由于一个未知的原因,例如,如果我增加第3列的大小,第2列的大小就会减小。 有人知道为什么会有这种行为吗

<table class="table" style="table-layout: fixed;width:1165px">
    <thead>
        <th style="width:137px">Col 1</th>
        <th style="width:137px">Col 2</th>
        <th style="width:98px">Col 3</th>
        <th style="width:98px">Col 4</th>
        <th style="width:98px">Col 5</th>
        <th style="width:72px">Col 6</th>
        <th style="width:104px">Col 7</th>
        <th style="width:101px">Col 8</th>
        <th style="width:80px">Col 9</th>
        <th style="width:60px">Col 10</th>
    </thead>
</table>

第1列
第2列
第3列
第4列
第5列
第6栏
第7栏
第8栏
第9栏
第10栏

谢谢。

代码中所有列的宽度加起来是985px(而不是1165px)

与其使用固定宽度的像素,不如使用百分比。除其他优点外,它还可以根据不同的屏幕大小重新调整大小

例如

<table class="table">
    <thead>
        <th style="width: 12%">Col 1</th>
        <th style="width: 12%">Col 2</th>
        <th style="width: 11%">Col 3</th>
        <th style="width: 11%">Col 4</th>
        <th style="width: 11%">Col 5</th>
        <th style="width: 10%">Col 6</th>
        <th style="width: 11%">Col 7</th>
        <th style="width: 10%">Col 8</th>
        <th style="width: 6%">Col 9</th>
        <th style="width: 6%">Col 10</th>
    </thead>
</table>

第1列
第2列
第3列
第4列
第5列
第6栏
第7栏
第8栏
第9栏
第10栏
如果希望表格本身具有固定的宽度,则可以简单地将宽度样式添加到整个表格:
(当然,更改为您要查找的宽度)