zl程序教程

您现在的位置是:首页 >  Java

当前栏目

CSS max-width: 0;

2023-02-18 16:29:49 时间

CSS,大家都知道max-width是要在宽度超过后才会生效,但今天我发现一个神奇的现象,

为表格td加上max-width: 0;可以让上下两个表格自动对齐,这句的作用到底是什么还有待研究,今天先在这里做个记录。

td.t{width:80px;}
td.c{max-width: 0;}

网路上能查到的相关max-width:0的资料非常的少,翻遍了整个度娘也没找到几条有用的信息,在这个帖子上发现了一些蛛丝马迹(https://stackoverflow.com/questions/19907020/what-does-max-width-0px-do

坛友Adam Botley说到:

max-width: 0px basically prevents the element from expanding itself. In the context of the linked post. It prevents the table cell from expanding based on what’s being written in the textarea.

基本意思是: max-width: 0px基本防止元素膨胀。在上下文中。它可以防止单元格根据文本区域的内容进行扩展。

本文采用 「CC BY-NC-SA 4.0」创作共享协议,转载请标注以下信息: 原文出处:Yiiven https://www.yiiven.cn/css-max-width.html