是否允许<button>具有display:grid?

时间:2018-08-13 05:02:10

标签: css css-grid

或更笼统地说,是否有不能用display:grid设置样式的元素?

考虑:

button,
div {
  display: grid;
  grid-template-columns: 50px 50px;
}


/* Nevermind these, they're just for a consistent display */

button,
div {
  border: 0;
  background-color: gray;
  color: black;
  width: 100px;
  text-align: center;
  font-family: sans-serif;
  font-size: 14px;
  padding: 0;
}
Button:
<button>
  <span>A</span>
  <span>B</span>
</button>
<br> 
Div:
<div>
  <span>A</span>
  <span>B</span>
</div>

Try it on JsFiddle

这是 Firefox (61.0.1)中的结果:

Both look the same

这是 Chrome (68.0.3440.106)中的结果:

Something is wrong with the button

Chrome似乎不喜欢我尝试在按钮上使用display:grid。这只是一个错误吗?还是出于某种目的?

1 个答案:

答案 0 :(得分:9)

显然这是Chrome上的错误,在这里进行了详细说明:

https://github.com/rachelandrew/gridbugs#10-some-html-elements-cant-be-grid-containers

并在此处跟踪:

https://bugs.chromium.org/p/chromium/issues/detail?id=375693

(我在这里看不到任何进展。如果已解决,请编辑答案,否则,我会记住的)