表属性的最小宽度和最大高度 [英] Min-width and max-height for table attributes

查看:166
本文介绍了表属性的最小宽度和最大高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表,我想定义 min-width max-height 属性。请参见下面的示例。

I have a table and I want to define the min-width and max-height properties. See example below.

我的问题是浏览器不接受它。如果我定义它在 td 它被忽略,如果我定义它在 div 元素内 td 元素,内容具有正确的最小和最大宽度,但表仍具有相同的大小。 (所以有很多可用空间:/)

My problem now is that the browser doesn't take it. If I define it on td it gets ignored, if I define it in an div element inside a td element, the content has the right min and max width, but the table still has the same size. (so there is a lot of free space :/)

如何解决这个问题?


我只是注意到,这个问题似乎只发生时,表是在全屏模式。但是,元素的最大宽度不能超过!

I just noticed that the problem seems to only occur when the table is in fullscreen mode. Nevertheless, an element shouldn't have more than the max-width than!

示例:

<html>
<head>
    <style type="text/css">
        td {
            border: 1px solid black;
        }

        html,body,.fullheight {
            height: 100%;
            width: 100%;
        }
        .minfield {
            max-width: 10px;
            border: 1px solid red;
            overflow: hidden;
        }
    </style>    
</head>

<body>
    <table class="fullheight">
        <tr>
            <td class="minfield">
                <div class="minfield">
                    <p>hallo</p>
                </div>
            </td>
            <td><p>welt</p></td>
        </tr>
    </table>
</body>
</html>


推荐答案

,因为'min-width'和'max-width'未定义为表格单元格。请参阅规范

For table cells the 'width' property should be used, as the 'min-width' and 'max-width' is undefined for table cells. See the specification:

在CSS 2.1中,min-width和max-width对表,内联表,表单元格,表列和列组的影响未定义。

"In CSS 2.1, the effect of 'min-width' and 'max-width' on tables, inline tables, table cells, table columns, and column groups is undefined."

要强制使用宽度,您可以尝试更改表格布局属性设置为固定。规范描述的算法很清楚。

To enforce the width, you may try to change the table-layout property to "fixed". The specification describes the algorithm pretty clear.

这篇关于表属性的最小宽度和最大高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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