Is a <button> allowed to have display:grid? [duplicate]

情到浓时终转凉″ 提交于 2019-11-27 17:19:36

问题


or, more generally, are there any elements that can't be styled with display:grid?

Consider:

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

This is the result in Firefox (61.0.1):

And this is the result in Chrome (68.0.3440.106):

Chrome seems to dislike that I'm trying to use display:grid on a button. Is this just a bug? Or is it intended somehow?


回答1:


Apparently it's a bug on Chrome which detailed here:

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

And tracked here:

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

(I don't see a progress here. If it fixed, please edit the answer or I will if I remember)



来源:https://stackoverflow.com/questions/51815477/is-a-button-allowed-to-have-displaygrid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!