css-grid

Create a CSS Grid that flows by column, with dynamic columns and rows based on content

眉间皱痕 提交于 2020-06-14 08:51:54
问题 I have a dynamic number of elements (all of equal dimensions). I want to position them in a grid, such that they are ordered in columns, with a dynamic number of columns based on the available container width, and with a dynamic number of rows based on the number of elements. For example, assuming there are 9 elements: 1 4 7 2 5 8 3 6 9 But if the container width expands: 1 3 5 7 9 2 4 6 8 Or shrinks: 1 6 2 7 3 8 4 9 5 This works fine when the items are positioned by row, but not by column.

Create a CSS Grid that flows by column, with dynamic columns and rows based on content

情到浓时终转凉″ 提交于 2020-06-14 08:51:54
问题 I have a dynamic number of elements (all of equal dimensions). I want to position them in a grid, such that they are ordered in columns, with a dynamic number of columns based on the available container width, and with a dynamic number of rows based on the number of elements. For example, assuming there are 9 elements: 1 4 7 2 5 8 3 6 9 But if the container width expands: 1 3 5 7 9 2 4 6 8 Or shrinks: 1 6 2 7 3 8 4 9 5 This works fine when the items are positioned by row, but not by column.

How to make this simple css-grid layout work in IE11

只谈情不闲聊 提交于 2020-06-13 05:52:09
问题 I'm building a prototype for a simple 3-panels slide thing. On the second panel, I'd like to use css-grid to have a simple way to divide the panel into 4 equal and responsive areas, 100% container's height. Here's the demo: http://jsfiddle.net/stratboy/obnkc2x5/1/ Some of the code: <div class="sub-grid-container"> <div class="sub-grid-item">sub 1</div> <div class="sub-grid-item">sub 2</div> <div class="sub-grid-item">sub 3</div> <div class="sub-grid-item">sub 4</div> </div> And the relevant

How to make this simple css-grid layout work in IE11

梦想与她 提交于 2020-06-13 05:51:05
问题 I'm building a prototype for a simple 3-panels slide thing. On the second panel, I'd like to use css-grid to have a simple way to divide the panel into 4 equal and responsive areas, 100% container's height. Here's the demo: http://jsfiddle.net/stratboy/obnkc2x5/1/ Some of the code: <div class="sub-grid-container"> <div class="sub-grid-item">sub 1</div> <div class="sub-grid-item">sub 2</div> <div class="sub-grid-item">sub 3</div> <div class="sub-grid-item">sub 4</div> </div> And the relevant

How to get Angular's <router-outlet> to work with CSS Grid

你说的曾经没有我的故事 提交于 2020-06-12 09:17:13
问题 I'm trying to create a layout with Angular 7 and CSS Grid. The problem I have is that the router-outlet only takes up one column in the second row. I have created a StackBlitz here. As you can see in app.component.css I want router-outlet (and any of its content) to take up grid-column: 2 / 5 , as of now it takes up 2 / 3. Is what I'm trying to achieve possible? 回答1: <router-outlet> has no size and does not have any content in it, the actual router content is the next element to it. Remove

How to get Angular's <router-outlet> to work with CSS Grid

不羁岁月 提交于 2020-06-12 09:16:55
问题 I'm trying to create a layout with Angular 7 and CSS Grid. The problem I have is that the router-outlet only takes up one column in the second row. I have created a StackBlitz here. As you can see in app.component.css I want router-outlet (and any of its content) to take up grid-column: 2 / 5 , as of now it takes up 2 / 3. Is what I'm trying to achieve possible? 回答1: <router-outlet> has no size and does not have any content in it, the actual router content is the next element to it. Remove

Create CSS grid layout with pure CSS

人盡茶涼 提交于 2020-06-06 07:54:45
问题 I trying to create a layout using CSS Grid like the image (any item is square): Code I'm trying: CSS .grid-container { padding: 20px; display: grid; grid-gap: 20px; grid-auto-rows: 1fr; grid-template-columns: repeat(2, 1fr); } .item { position: relative; background: #ccc; } /* Square */ .item:after { content: ''; display: block; padding-top: 100%; } @media screen and (min-width: 640px) and (max-width: 1023px) { /* 640 ~ 1023 */ .grid-container { grid-template-columns: repeat(3, 1fr); } .item

Create CSS grid layout with pure CSS

不打扰是莪最后的温柔 提交于 2020-06-06 07:54:18
问题 I trying to create a layout using CSS Grid like the image (any item is square): Code I'm trying: CSS .grid-container { padding: 20px; display: grid; grid-gap: 20px; grid-auto-rows: 1fr; grid-template-columns: repeat(2, 1fr); } .item { position: relative; background: #ccc; } /* Square */ .item:after { content: ''; display: block; padding-top: 100%; } @media screen and (min-width: 640px) and (max-width: 1023px) { /* 640 ~ 1023 */ .grid-container { grid-template-columns: repeat(3, 1fr); } .item

Different height of CSS grid cells [duplicate]

允我心安 提交于 2020-05-25 11:26:38
问题 This question already has answers here : CSS-only masonry layout (2 answers) Closed 2 years ago . How can I move up the "content" and the "right" block responsive? The problem is I can't use sub nested grid. I don't need hacks: no margin-top because header can be a different height. No javascript. Only pure CSS. If at all possible. Now my markup looks like this: .wrapper { border: 1px solid red; display: grid; grid-template-columns: 1fr 2fr 1fr; grid-template-areas: "aside header header"

Change the number of columns and rows in a grid as the number of items increase

拟墨画扇 提交于 2020-05-24 03:32:46
问题 I have to design a responsive grid. The grid should change based on the number of items (instead of the size of the screen). From 5 to 6 items should be 2x3, from 7 to 9 items should be 3x3, from 10 to 12 items should be 3x4, from 13 to 16 items should be 4x4, and so on... Is this something I can do using CSS Grid? This is what I've tried: <main> <figure> <img src="https://placekitten.com/600/400" alt=""> </figure> <figure> <img src="https://placekitten.com/600/400" alt=""> </figure> <figure>