将表格单元格锁定为默认大小,而不考虑内容 [英] Lock table cells to their default size regardless of content

查看:172
本文介绍了将表格单元格锁定为默认大小,而不考虑内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有

<table>
    <tr>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
    </tr>
</table>

table
    { width: 100%; height: 100%; }

每个单元格占用表格的四分之一,并且表格伸展以适应窗口。

Each cell takes up an equal quarter of the table, and the table stretches to fit the window.

如何防止这些表格单元格自行调整大小以适应单元格内的内容(同时仍适合表格的容器)?

How can I prevent these table cells from resizing themselves to fit the content within the cells (while still fitting the table's container)?

谢谢

推荐答案

您可以尝试 table-layout:fixed; - 这将布局设置为一定的固定大小(在CSS中指定),忽略单元格的内容,因此单元格的宽度不会改变。我不知道这是否会影响垂直布局。

You could try table-layout:fixed; - this sets the layout to a certain fixed size (specified in CSS) and ignores the content of the cells, so the width of the cell never changes. I'm not sure if this affects vertical layout or not.

更多关于w3schools 的信息。

这篇关于将表格单元格锁定为默认大小,而不考虑内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆