css-grid

Table striping rows in CSS Grid

狂风中的少年 提交于 2019-12-02 00:37:03
问题 I'm trying to replace a grid of data & interactive components that had been set up in Bootstrap with a CSS Grid-based layout. I was able to replicate the grid, but am having trouble getting something like table striping working.From what I understand of CSS Grid, since I know the number of columns that will be displayed ahead of time but not the number of rows (dynamically generated data from the server), I need to use grid-template-columns: repeat(3, auto); , and each cell must be a direct

Stretch an element to the end of the automatically calculated grid, not just the explicit grid

人走茶凉 提交于 2019-12-02 00:30:49
问题 In a CSS grid, you can use grid-column: 1 / -1 to stretch an element across the entire explicit grid. However, if you add new elements and the grid automatically has more columns than explicitly stated, this doesn't have the same effect. Is there any value I can put instead of -1 that will force the item to stretch all the way to the end of the grid? In the following example, because grid-auto-flow is set to column , the extra elements add new columns. I want the .stretch element to stretch

How to use all available space vertically in a CSS Grid?

点点圈 提交于 2019-12-01 23:50:16
问题 I'm trying to build a web layout with a title bar, a nav header, a footer and a main content area in the middle (split in two for a sidebar and main view). I intend to use CSS Grid layout for it. My current code manages it all, except: The main content (and sidebar) adjust to its content. And that's not what I want. How can I make that 3rd grid row fill all remaining vertical space? * { box-sizing: border-box; } .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)

Remove a pseudo-element when there is only one child element

我怕爱的太早我们不能终老 提交于 2019-12-01 23:29:26
I use an invisible pseudo-element ( ::after ) that occupies the last slot in the container. But if there is only one element, I'd like to position it in the center. So in order to do it I need to "remove" the pseudo-element in that case. How do I do it if it's possible? .main { background: #999; margin: 0 auto; width: 500px; display: flex; flex-wrap: wrap; justify-content: space-between; } .box { background: #7ab9d7; color: #555; height: 30px; width: 30%; margin-bottom: 30px; text-align: center; font-size: 30px; padding-top: 120px; } .main::after { height: 0; width: 30%; content: ""; } <div

Width of widest element sets width of all siblings in the row

我们两清 提交于 2019-12-01 22:30:52
I've read a lot of tutorials about CSS flex boxes and CSS grids, but frankly I just can't figure out how to do this simple(?) thing. All I want is for the elements in a container to all be as wide as the widest element. I don't want them to fill up the whole width of the container, just all grow to the maximum width. Can that be done with CSS? Consider this HTML: <div class="container"> <button>a normal button</button> <button>tiny</button> <button>a really, really, really wide button</button> </div> That produces something like this: What I want is something like this, where they're all the

Placing the footer out of view using CSS grid

十年热恋 提交于 2019-12-01 22:19:23
I have a header that is 70px high, the main content which I want to fill the rest of the screen and then a 70px footer. I am trying to find the most simple approach of hiding a footer. This works with the footer in view - see jsfiddle and snippet below: * { margin: 0; padding: 0; } *, *::before, *::after { box-sizing: border-box; } body { display: grid; margin: 0px; grid-gap: 10px; height: 100vh; grid-template-columns: [side__nav] 250px [main] 1fr; grid-template-rows: [header] 70px auto [footer] 70px; } .header { grid-column: main; grid-row: 1; background: pink; } .side__nav { grid-column:

Grid CSS container that scrolls horizontally when children use grid-column?

血红的双手。 提交于 2019-12-01 21:11:41
问题 CODEPEN: https://codepen.io/matthewharwood/pen/ywKNVg I'm trying to achieve this layout in GridCSS: Problems: I'm having trouble making the children .elements overflow their parent .grid when using grid-column: span 4; . Note: Children will peak on mobile Grid will have scroll bars if children overflow Children perfectly follow the grid. Question: Is it possible to make CSS Grid Items overflow with a scroll bar when its children are aligned to the grid using grid-column ? if so, what

Grid CSS container that scrolls horizontally when children use grid-column?

梦想与她 提交于 2019-12-01 20:51:57
CODEPEN: https://codepen.io/matthewharwood/pen/ywKNVg I'm trying to achieve this layout in GridCSS: Problems: I'm having trouble making the children .elements overflow their parent .grid when using grid-column: span 4; . Note: Children will peak on mobile Grid will have scroll bars if children overflow Children perfectly follow the grid. Question: Is it possible to make CSS Grid Items overflow with a scroll bar when its children are aligned to the grid using grid-column ? if so, what properties am I missing? If not, is are there any work arounds to achieve these layouts shown above, when using

How to use all available space vertically in a CSS Grid?

删除回忆录丶 提交于 2019-12-01 20:33:32
I'm trying to build a web layout with a title bar, a nav header, a footer and a main content area in the middle (split in two for a sidebar and main view). I intend to use CSS Grid layout for it. My current code manages it all, except: The main content (and sidebar) adjust to its content. And that's not what I want. How can I make that 3rd grid row fill all remaining vertical space? * { box-sizing: border-box; } .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); grid-template-rows: min-content min-content auto min-content; grid-gap: 10px; grid-template-areas:

Why are only some of my CSS Grid boxes expanding when I hover over them?

╄→гoц情女王★ 提交于 2019-12-01 18:16:31
问题 I'm new to grids in CSS but I want to give it a try. I have a grid with 3x3 boxes. When I hover over a box it should should out the complete row... but that's not working. When I hover over 1 it fills out the screen completely, and when I hover over 3 my screen starts to blink and it's not working. .container { display: grid; grid-gap: 10px; grid-template-columns: repeat(3, minmax(100px, auto)); grid-template-rows: repeat(3, minmax(100px, auto)); } [class^="item"] { text-align: center; box