css-grid

Prevent div growing/stretching when creating a dynamic grid

跟風遠走 提交于 2021-01-07 03:07:16
问题 I am working on a dynamic image grid, and I cannot get the grid to stay in a container. The idea is rather simple, add as many boxes to the container as I like, using jQuery, and as they are added, shrink them to fit the container without adding scroll bars, or running off the screen. This is working with adding columns but when adding rows it just keep running off the bottom of the screen. How do I fix the container div so as rows are added, the image shrinks instead of adding rows with

Prevent div growing/stretching when creating a dynamic grid

旧巷老猫 提交于 2021-01-07 03:06:37
问题 I am working on a dynamic image grid, and I cannot get the grid to stay in a container. The idea is rather simple, add as many boxes to the container as I like, using jQuery, and as they are added, shrink them to fit the container without adding scroll bars, or running off the screen. This is working with adding columns but when adding rows it just keep running off the bottom of the screen. How do I fix the container div so as rows are added, the image shrinks instead of adding rows with

CSS grid with fixed sidebar

一个人想着一个人 提交于 2021-01-05 09:41:31
问题 I need a fixed header and sidebar on my site, beyond a central div. The sidebar should have a scrollbar of its own, just like the central div. I thought that grid layout would be the way to do this, but I can't avoid the body to display a common scrollbar, instead of each container displaying its own. How should I do it? Is grid indeed the simpler solution? body { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr; margin: 0; } header { background-color: #add790; grid

Set minimum and maximum widths to grid column using percentages

巧了我就是萌 提交于 2021-01-05 06:44:46
问题 When I set the first column in a CSS grid column to a minimum percentage, the column width does not observe the minimum. Example: grid-template-columns: minmax(50%, 75%) 1fr; With these values, as the viewport narrows the first column keeps shrinking horizontally until it finally collapses and disappears. Likewise, stretching the screen makes the first column wider as you go, so that eventually its wider than 3/4 of the total grid width. (Even so, at most grid widths the proportions of the

Make flex items wrap in a column-direction container

无人久伴 提交于 2021-01-01 07:15:39
问题 So, to wrap elements in a flex div using a row layout all I have to do is this: div { display: flex; flex-direction: row; /* I want to change this to column */ flex-wrap: wrap; /* wrap doesn't seem to work on column, only row */ } <div> <p>these</p> <p>will</p> <p>wrap</p> </div> This works for my rows, but I want to make it work for my columns as well. I tried just changing flex-direction to column , but it doesn't seem to be working. Does anyone know how to get this functionality? 回答1:

CSS Grid : How Auto placement algorithm works

做~自己de王妃 提交于 2021-01-01 04:14:32
问题 I was going through the example provided in MDN article on grid-auto-flow to understand how the auto-placement algorithm works in CSS grid. Here's how the example is defined (you can change the select option to change value of grid-auto-flow property here): function changeGridAutoFlow() { var grid = document.getElementById("grid"); var direction = document.getElementById("direction"); var dense = document.getElementById("dense"); var gridAutoFlow = direction.value === "row" ? "row" : "column"

How do I make a responsive grid with a checkered pattern?

北城以北 提交于 2020-12-29 12:56:21
问题 I have a responsive grid layout. There can be any number of columns depending on the window width. I am trying to make the grid have a checkered pattern, so I use the odd and even selectors to color the grid cells. But it only works when the number of columns is odd. When the number of columns is even, it becomes a striped pattern. Is there a CSS property/selector to solve this, or a better way to do it? Here's the simplified code of my project showing the problem: .grid { display: grid;

How to span a grid cell across all dynamic rows? [duplicate]

我只是一个虾纸丫 提交于 2020-12-11 06:10:36
问题 This question already has answers here : Make a grid item span to the last row / column (4 answers) Closed 9 days ago . The attached example works properly, the first child of .container is spanned across all rows, but the problem is that the grid-row-end value is dependent on a number of children of div.container . Is it possible to do it without the magic constant (4) and WITHOUT changing an HTML structure. Unfortunately using grid-row-end:-1 is possible only for the explicit grids.

How to span a grid cell across all dynamic rows? [duplicate]

我是研究僧i 提交于 2020-12-11 06:10:14
问题 This question already has answers here : Make a grid item span to the last row / column (4 answers) Closed 9 days ago . The attached example works properly, the first child of .container is spanned across all rows, but the problem is that the grid-row-end value is dependent on a number of children of div.container . Is it possible to do it without the magic constant (4) and WITHOUT changing an HTML structure. Unfortunately using grid-row-end:-1 is possible only for the explicit grids.

How to span a grid cell across all dynamic rows? [duplicate]

…衆ロ難τιáo~ 提交于 2020-12-11 06:08:40
问题 This question already has answers here : Make a grid item span to the last row / column (4 answers) Closed 9 days ago . The attached example works properly, the first child of .container is spanned across all rows, but the problem is that the grid-row-end value is dependent on a number of children of div.container . Is it possible to do it without the magic constant (4) and WITHOUT changing an HTML structure. Unfortunately using grid-row-end:-1 is possible only for the explicit grids.