简体   繁体   English

带有 `max-height: 0` 的 Fieldset 在 Chrome v87+ 上总是溢出

[英]Fieldset with `max-height: 0` always overflows on Chrome v87+

On Chrome 86, a fieldset with a max-height less than the height of its contents and overflow: hidden would hide the contents of that fieldset .在Chrome 86,一个fieldset具有max-height小于其内容和高度的overflow: hidden将隐藏的内容fieldset

Chrome 86 溢出

However, on Chrome v87 ( 87.0.4280.67 ), this apparently changed.然而,在 Chrome v87 ( 87.0.4280.67 ) 上,这显然改变了。

Chrome 87 溢出

If a height is set that is less than the contents, then it correctly hides the overflow.如果设置的height小于内容,则它会正确隐藏溢出。 This bug only appears with max-height .此错误仅与max-height一起出现。

The following snippet will render correctly on Chrome v86 and earlier, Firefox, and Safari.以下代码段将在 Chrome v86 及更早版本、Firefox 和 Safari 上正确呈现。 On Chrome 87 the first fieldset will overflow.在 Chrome 87 上,第一个fieldset溢出。

 fieldset { /* Reset user-agent styles */ padding: 0; margin: 0; border: 0; overflow: hidden; /* Misc */ background: cyan; margin-top: 1em; }
 <fieldset style="max-height: 9px"> This should be half-visible (<code>max-height: 9px; overflow: hidden</code>) </fieldset> <fieldset style="height: 9px"> This should also be half-visible (<code>height: 9px; overflow: hidden</code>) </fieldset>

Is there a workaround for this?有解决方法吗? Is there a Chromium bug filed for this?是否有为此提交的 Chromium 错误? I've tried searching, but haven't found anything definitive.我试过搜索,但没有找到任何确定的东西。 There is a Chromium ticket, as detailed here .有一张 Chromium 票,详见此处

As a workaround you can add this to the fieldset :作为解决方法,您可以将其添加到字段集

display: -webkit-box; or display: -webkit-inline-box;display: -webkit-inline-box;

 fieldset { /* Reset user-agent styles */ padding: 0; margin: 0; border: 0; overflow: hidden; /* Misc */ background: cyan; margin-top: 1em; }
 <fieldset style="max-height: 9px; display: -webkit-box;"> This should be half-visible (<code>max-height: 9px; overflow: hidden</code>) </fieldset> <fieldset style="height: 9px"> This should also be half-visible (<code>height: 9px; overflow: hidden</code>) </fieldset>

Turns out this is a known Chromium bug: Issue 1151858 .原来这是一个已知的 Chromium 错误: 问题 1151858

As, of December 2020, this has been merged into their main branch and verified that the issue is no longer reproducible.截至 2020 年 12 月,这已合并到他们的主要分支中,并验证该问题不再可重现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM