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

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)

Flexbox: flex-start/flex-end, self-start/self-end, and start/end; What’s the difference?

The values flex-end and flex-start (among others) were created for use with flex layout. However, the W3C has been developing the Box Alignment Module, which establishes a common set of alignment properties and values for use across multiple box models, including flex, grid, table and block. So what you’re seeing are the newer values that … Read more

Can I make a CSS grid with dynamic number of rows or columns?

Okay, after reading the MDN reference, I found the answer! The key to dynamic rows (or columns) is the repeat property. const COLORS = [ ‘#FE9’, ‘#9AF’, ‘#F9A’, “#AFA”, “#FA7” ]; function addItem(container, template) { let color = COLORS[_.random(COLORS.length – 1)]; let num = _.random(10000); container.append(Mustache.render(template, { color, num })); } $(() => { const … Read more

How do browsers calculate width when child depends on parent, and parent’s depends on child’s

To explain this, I will start with a more simplified example that will produce the same output: <div style=”display:inline-block”> <img src=”https://via.placeholder.com/1000×100″> </div> <div style=”display:inline-block”> <img src=”https://via.placeholder.com/1000×100″ style=”max-width:100%”> </div> <div style=”display:inline-block”> <!– even a big explicit width specified won’t change the behavior –> <img src=”https://via.placeholder.com/1000×100″ style=”wdith:2000px;max-width:100%”> </div> <div style=”display:inline-block”> <img src=”https://via.placeholder.com/1000×100″ style=”width:100%”> </div> We have an … Read more

How to flatten nested divs to display them in a CSS grid?

You can use display:contents (https://caniuse.com/#feat=css-display-contents) to overcome this: #table { display: grid; grid-template-columns: auto 1fr; grid-gap:10px; } #table > div { display:contents; } <div id=”table”> <div> <div> this is something long on the first row </div> <div> short 1st row </div> </div> <div> <div> wazaa 2nd row </div> <div> wazii 2nd row </div> </div> </div> … Read more

Can flex items wrap in a container with dynamic height?

You can use CSS columns and the height will adapt based on the content. ul { column-count: 4; list-style: none; background: #eee; } <ul> <li>A</li> <li>B</li> <li>C</li> <li>D</li> <li>E</li> <li>F</li> <li>G</li> <li>H</li> <li>I</li> <li>J</li> <li>K</li> <li>L</li> <li>M</li> <li>N</li> <li>O</li> <li>P</li> <li>Q</li> <li>R</li> <li>S</li> <li>T</li> <li>U</li> <li>V</li> <li>W</li> <li>X</li> <li>Y</li> <li>Z</li> </ul>