有没有办法使网格容器的子元素不参与该子元素上的网格布局other than using 100 or 101?
例如,给出一些简单的东西,比如:
body {
display: grid;
grid-template-columns: auto auto;
grid-template-rows: auto auto;
}
<div>Element One</div>
<div>Element Two</div>
<div>Element Three</div>
<div>Element Four</div>
<custom-web-component id="exemptedElement">Exempted Element</custom-web-component>
有没有可能通过css或其他方式告诉最后一个元素不要参与网格布局?
我知道我可以在该元素上设置position: fixed;
,它也会这样做,但这会在该组件中产生下游影响(例如,带有position: absolute;
的子体将被锁定到视区,而不是预期的文档).
我知道我也可以在那个元素上设置display: contents
,但它不会参与,将布局推迟到它的子元素……但这也会对下游产生影响,这意味着这个主要组件的子组件都需要小心上面的固定/绝对定位问题.
Note: I do not have control over the fact that the custom-web-component is sometimes being added to a grid container. So I'm trying to find some way to "Break out" of it when that does happen.个