关于html:Flex / Grid布局不适用于按钮或字段集元素

Flex / Grid layouts not working on button or fieldset elements

我试图将

调整后的CSS(定位为span)

1
2
3
4
5
button > span, p {
    display: flex;
    flex-direction: row;
    justify-content: center;
}

修改后的演示

参考/错误报告


从Chrome 83开始,button现在可以用作inline-grid/grid/inline-flex/flex,您可以在此处查看有关此新功能的更多信息

这是一个代码段(适用于使用Chrome 83及更高版本的用户)

1
2
3
4
5
6
7
8
button {
  display: inline-flex;
  height: 2rem;
  align-items: flex-end;
  width: 4rem;
  -webkit-appearance: none;
  justify-content: flex-end;
}
1
2
3
4
5
6
7
<!--

The align-items keyword should fail in Chrome 81 or earlier, but work in Chrome 83 or later. To see the error, the button needs styles that make it more of an extrinsic container. In other words, it needs a height or width set.
 
-->
<button>Hi</button>
<input type="button" value="Hi">