css-grid

Make grid items overlap

懵懂的女人 提交于 2019-12-01 07:36:53
问题 I am trying to achieve a css grid pattern where the header is overlaying the next row. I have added a snippet of my code with the header on top, the attached image should show you what I am trying to achieve. Thanks body { display: grid; grid-template-areas: "header header header" "nav article ads" "footer footer footer"; grid-template-rows: 80px 1fr 70px; grid-template-columns: 20% 1fr 15%; grid-row-gap: 10px; grid-column-gap: 10px; height: 100vh; margin: 0; } /* Stack the layout on small

Create a Table with CSS grid

南笙酒味 提交于 2019-12-01 07:20:34
I'm trying to create a table using CSS grid, with equal columns based on the content. I want to avoid using <table> . This is a follow-up to this question: Auto-adjusting columns with CSS grid What I'm trying to achieve: This table works: https://codepen.io/anon/pen/baExYw But I want to wrap the each row in a div , which unsurprisingly breaks the table. This table is broken: https://codepen.io/anon/pen/qpbMgG app.html <div class="wrapper"> <div class="box a">col 1</div> <div class="box b">col 2</div> <div class="box c">col 3</div> <!-- Table Row --> <div class="row"> <div class="box d">short

How to create a CSS Grid Layout box that spans 2 columns and 2 rows?

允我心安 提交于 2019-12-01 07:10:32
问题 I've created a grid layout following the newest CSS Grid spec, but am not completely familiar with it yet. I'm trying to create the following layout without having to define grid areas for each grid child. codepen body { max-width: 1024px; margin: 10px auto; } .grid { display: grid; grid-gap: 10px; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; grid-template-areas: "a a b" "a a c" "d e f"; } .grid__thing { background-color: rebeccapurple; } .a { grid-area: a; } .b { grid

Can auto margins work in CSS Grid like they do in Flexbox?

…衆ロ難τιáo~ 提交于 2019-12-01 06:11:53
问题 As far as I understand, anything flexbox can do, css-grid should also be able to do (usually more verbosely). Yet I cannot figure out how to mimic a flexbox with an item pushing off the others with margin: auto ul { list-style-type: none; padding: 0; display: flex; flex-direction: column; outline: 1px solid red; height: 200px; background-color: lime; } li { background-color: cornsilk; } li:last-of-type { margin-top: auto; } <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> </ul> See how all

sticky position on css grid items

半腔热情 提交于 2019-12-01 03:24:22
I've looked at other examples of this on here but can't find one that makes this work. I want the sidebar (section) to be sticky while the page scrolls. the position: sticky works if I put it on the nav, so my browser def supports it. main { display: grid; grid-template-columns: 20% 55% 25%; grid-template-rows: 55px 1fr; } nav { background: blue; grid-row: 1; grid-column: 1 / 4; } section { background: grey; grid-column: 1 / 2; grid-row: 2; position: sticky; top: 0; left: 0; } article { background: yellow; grid-column: 2 / 4; } article p { padding-bottom: 1500px; } <main> <nav></nav> <section>

Text not wrapping in CSS Grid

☆樱花仙子☆ 提交于 2019-12-01 03:17:26
I've been experimenting with CSS Grid and am stuck on finding the most effective means to have text wrap around a <div> element that is positioned partially on-top of two other <div/> elements. Basically, like in the image below, I want the text in the red and blue divs to wrap around the yellow div that has been partially positioned in the columns and rows of the other two elements. Obviously, this is a Grid based layout, so I'm not interested in doing this with typical floats. How can I use CSS Grid to achieve this effect? Here is my css and html: .grid { display: grid; grid-template-columns

Why does grid-gap cause an overflow?

穿精又带淫゛_ 提交于 2019-12-01 02:59:41
Why do I have an overflow on the X axis in the following snippet? The overflow is generated once I apply grid-gap: 10px on my .body grid container. div:not(.header):not(.body):not(.row) { border: 1px solid grey; } .header { margin-top: 20px; display: grid; grid-gap: 10px; grid-template-areas: "header-left header-right-up" "header-left header-right-down"; grid-template-rows: 40px 40px; grid-template-columns: minmax(50px, 200px) auto; } .header-left { grid-area: header-left; } .header-right-up { grid-area: header-right-up; } .header-right-down { grid-area: header-right-down; } .body { margin-top

How can I force this CSS grid to wrap to a new line without specifying minmax sizes?

痞子三分冷 提交于 2019-12-01 01:37:49
I come from a heavy div/float background to build responsive sites (e.g. Bootstrap 3, Foundation) and used Flex box briefly but have been attempting to use Grid everywhere since it's been really great at solving a number of problems. I seem to run into "simple" problems like this all too often and feel like I'm missing some basics, and can't find the answer in docs. Anyways, to the code. Given a grid setup like so: display: grid; grid-auto-columns: max-content; grid-auto-flow: column; the content doesn't wrap to a new row once it's filled the width of its parent element. Ideally, I'd be able

How is “grid-template-rows: auto auto 1fr auto” interpreted?

余生长醉 提交于 2019-12-01 01:22:50
问题 Recently, I created a layout using CSS grid. While this works well, I'm confused by how it works. Specifically, I'm confused about the line grid-template-rows: auto auto 1fr auto; . What ended up happening here is that the header and footer sized according to the content, which makes sense since they spanned the width of the page. The article itself sized according to its content. But, the "title" and "nav" were split such that the title sized according to content and nav took the rest of the

How to vertically align objects in CSS when working with CSS grids? [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-11-30 18:34:18
This question already has an answer here: Centering in CSS Grid 5 answers I have come across this problem recently. Lets suppose I have a simple <h1> tag and I want to center it vertically, so even when I re-size the window, it will remain in the middle of one of my grid box rows, neglecting its horizontal position. I know that when it comes to grid containers, vertical-align has no effect. So what would be the solution? This question has been marked as a duplicate, however, the other question asks about centering text horizontally, whereas, here, I'm asking about vertical centering.