Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

css

css-grid

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):

Both look the same

And this is the result in Chrome (68.0.3440.106):

Something is wrong with the button

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?

like image 523
Cássio Renan Avatar asked Aug 13 '18 05:08

Cássio Renan


People also ask

Can you use repeat in grid template areas?

You can also use the shorthand repeat code like above to make the columns repeat. For example, “grid-template-columns:repeat (9, 1fr);” shows the combined commands that specify the fraction code and the number of columns.

How do you repeat a CSS Grid?

The repeat() function takes two arguments: repeat count: the first argument specifies the number of times that the track list should be repeated. It is specified with an integer value of 1 or more, or with the keyword values auto-fill or auto-fit .

Is it safe to use CSS grids?

It is definitely safe to use.

What is the grid button?

A button grid is a group of similar buttons, such as buttons for products, operations, or payments. Microsoft Dynamics AX for Retail POS can display up to five button grids in a screen layout. When you create a new button grid, buttons are created based on the number of columns and rows that you specify.


1 Answers

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)

like image 120
Mosh Feu Avatar answered Sep 20 '22 19:09

Mosh Feu