html - 调整表中的列宽 (CSS/HTML)

标签 html css

我一直试图让移动设备上的列宽变为 50%,但我尝试过的所有方法都没有奏效。这是 css。

@media (max-width: 768px) {

#customTable tbody { float: left; }
#customTable thead { float: left; }
#customTable thead { min-width: 120px }
#customTable td { display: block }
#customTable th { display: block }
#customTable {table-layout: fixed;}
#customTable td {width: 50%;}
#customTable td {height: 20px; overflow: hidden;}
#customTable div {height: 20px;overflow: hidden;}
}

这是html

 <div class="table">
<table id="customTable" class="table" style="width: 100%">
<thead>
    <tr>
        <th><LABEL>Test 1</LABEL></td>
        <th><LABEL>Test 2</LABEL></td>
        <th><LABEL>Test 3</LABEL></td>
        <th><LABEL>Test 4</LABEL></td>
    </tr>
    </thead>
    <tr>                
        <td><LABEL>Test</LABEL></td>
        <td><LABEL>Test</LABEL></td>
        <td><LABEL>Test</LABEL></td>
        <td><LABEL>Test</LABEL></td>
    </tr>

</table>
</div>

最佳答案

如果你想调整列宽,使用表格,你实际上需要告诉它不再像表格一样工作。

例如在您的 #customTable td 上使用 display:blockwidth:50% 并从那里开始工作,就好像它们是 block 元素一样。

关于html - 调整表中的列宽 (CSS/HTML),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45871772/

相关文章:

RTL 形式的 HTML 标签

html - Wordpress 对齐问题

html - td 内的表格不占用全宽

CSS 在中心并排对齐两个 DIV。绝对位置

html - 重新排列页面上的默认列(-webkit-column,-moz-column)顺序?

html - 为什么页脚上方的边距比其余部分小?

javascript - css 破烂的底部,是什么意思?

html - 我怎样才能用 3 个图像列悬停?

html - 右图,左图有效,但左图,右图无效(对于网站)

css - 为什么 margin 是: auto not being calculated correctly here