css-grid

What is an alternative to css subgrid?

我的未来我决定 提交于 2019-11-28 13:34:05
I'm working on a page with a pretty simple layout - basically a data table, but using grid layout so that the columns will adjust nicely depending on content size. I want to make the rows sortable (using jQuery), so I need to find a way to wrap all the cells of a same row in a container. display: subgrid; I've tried using subgrid but it seems it's not much supported at the moment.. Obviously, just nesting a grid doesn't work as it won't sync the column sizes between different grids.. Any idea on how to achieve that? Here is my pen so far: https://codepen.io/anon/pen/PEjqgx Depending on the

CSS Grid with variable number of “auto” rows, but one row should take “1fr”

半城伤御伤魂 提交于 2019-11-28 12:14:49
I'm fiddling around with a CSS grid-based frontend and the following behaviour is required over and over and over again in different parts of the frontend: A grid with a variable number of rows. Every row should have a variable size (auto will do). The last row should always take up all the remaining space. So in the case I happen to need five rows, this does the trick: .myGridForFiveRows { display: grid; grid-template-rows: auto auto auto auto 1fr; } However, I'd really like a stylesheet that yields the correct behaviour for any given number of rows. I thought maybe I could somehow use repeat

Does CSS Grid have a flex-grow function?

喜夏-厌秋 提交于 2019-11-28 12:00:29
Is there an analog to flex-grow for the grid property ? I'd like my grid areas to accomodate the content they receive but have some areas take more place than others like flex-grow for flex . Practically, in the example below I'd like the turquoise to be invisible because it accomodates its content. The footer to be invisible as well because it has no content. The middle section take the remaining of the page like flex-grow . More practically, I'd like this code: .ctnr { display: grid; min-height: 100vh; grid-template-areas: "header header" "nav main" "footer footer"; } .test { background:

How to make CSS Grid items take up remaining space?

╄→гoц情女王★ 提交于 2019-11-28 11:57:49
I have a card built with CSS Grid layout. There might be an image to the left, some text to the right top and maybe a button or a link at the right bottom. In the code below, how can I make the green area take up as much space as possible and at the same time make the blue area take up as little space as possible? The green should push the blue area down as far as possible. https://jsfiddle.net/9nxpvs5m/ .grid { display: grid; grid-template-columns: 1fr 3fr; grid-template-areas: "one two" "one three" } .one { background: red; grid-area: one; padding: 50px 0; } .two { background: green; grid

css-grid creates an imaginary column

爷,独闯天下 提交于 2019-11-28 11:50:39
I am creating a simple form, where I want to have this kind of layout So far so good, very simple 2 columns with a nested 2 columns, all of them defined with 0.5fr which should be the half of "free-space" if I understood correctly. But, if I try to reduce the screen, this happens. even if I have NO media queries. if you debug with chrome devtools you can see it's creating a 3rd column from nowhere without any element. Any idea? https://stackblitz.com/edit/js-zzm4gy?file=index.html h1, h2 { font-family: Lato; } .form{ border: 1px solid black; text-align: center; display: grid; grid-template

Why grid-template-rows track pattern does not repeat like grid-template-columns

二次信任 提交于 2019-11-28 11:02:43
问题 Here is a simple grid (there are a total of twenty .grid_item s): <div class="grid"> <h1 class="grid_item">300 px row, 1fr column</h1> <h1 class="grid_item">300 px row, 1fr column</h1> <h1 class="grid_item">300 px row, 1fr column</h1> <h1 class="grid_item">1fr row, 1fr column</h1> <h1 class="grid_item">1fr row, 1fr column</h1> <h1 class="grid_item">1fr row, 1fr column</h1> <h1 class="grid_item">100 px row, 1fr column </h1> <h1 class="grid_item">100 px row, 1fr column </h1> <h1 class="grid

How to limit the amount of columns in larger viewports with CSS Grid and auto-fill/fit?

故事扮演 提交于 2019-11-28 09:07:32
问题 I'm starting to work with CSS Grid, I've been reading about the properties to help with responsiveness; so I'm trying to build a small grid with 6 elements; my intention is for them to show as 2 rows on larger devices like this: And also to show them all stacked on smaller devices,so everything is good regarding the smaller devices, I'm using auto-fill so it stays responsive, however if I the view the page on a laptop screen or desktop it is able to fill one more column and ends up looking

How to hide implicit grid rows?

ぐ巨炮叔叔 提交于 2019-11-28 08:19:42
问题 The snippet below uses CSS Grid to increase the number of columns for wide containers. For narrow containers (e.g. uncomment width: 80vw or resize the example), it adds implicit rows (only 2 are explicit in the grid-template-rows property). How can I maintain only 2 rows, making the grid items that "overflow" the 2-by-n grid hidden? .wrapper { border: 2px solid #f76707; background-color: #fff4e6; display: grid; /* width: 80vw; */ grid-template-columns: repeat(auto-fill, 200px); grid-template

How to make a fixed column in CSS using CSS Grid Layout?

落花浮王杯 提交于 2019-11-28 05:05:21
I've made a simple site with a #container div that is parent to two divs: #left and #right , by using Grid Layout : Is there any way to make the left column fixed? I'd like the left text to persist on its position, and the right text to be scrollable as it is now. Adding position: fixed to #left breaks the layout. I'm aware that this question has been already solved, but I'd appreciate a way to make it work with the grid layout. Thanks. body { margin: 0 0 0 0; } #container { display: grid; grid-template-columns: 50% 50%; } .section { padding: 5% 5% 5% 5%; } #left { background-color: aquamarine

CSS grids: align square cells with container edges with consistent grid gap?

…衆ロ難τιáo~ 提交于 2019-11-28 04:44:53
问题 The goal is to align square cells with their container's leading and trailing edges while achieving a consistent gap between cells on each row, and between each row. This Codepen is close, but there are two problems: (1) vertical gaps are different from horizontal gaps; and (2) the squares are flush with the leading edge, but not the trailing edge. https://codepen.io/anon/pen/wREmjo ul { display: grid; width: 260px; grid-template-columns: repeat(auto-fit, minmax(40px, 1fr)); grid-auto-rows: