css-grid

Is there a way to center one of the flex/grid children(more than three) and with different widths?

流过昼夜 提交于 2019-12-08 15:21:16
问题 Have a look at the snippet. There is a red line to show center of the parent. Is there a way to horizontally center middle block ? CSS-grid solution will also work. I can imagine 2 solutions: position: absolute wrap 2 left blocks and 2 right blocks with wrappers of same width But I'm not happy with any of them. .wrapper { display: flex; align-items: center; justify-content: space-between; height: 100px; padding: 5px; position: relative; background: teal; color: #fff; font-family: sans-serif;

How to set the maximum width of a column in CSS Grid Layout?

前提是你 提交于 2019-12-08 14:29:54
问题 What I want to achieve: Using CSS Grid Layout, to have a page with a right column which size is derived from its content, but only up to 20% of the window width. How I thought it would work: div { border-style: solid; } #container { width: 300px; height: 300px; display: grid; grid-template-columns: 1fr minmax(auto, 20%); } <div id="container"> <div> some content </div> <div> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec cursus eu leo ac ultrices. Vivamus ornare, orci sed

Fluidly scaling items in CSS Grid layout

自作多情 提交于 2019-12-08 07:50:51
问题 I've created a layout below using display: grid , I've used the old padding-top trick to have fluid square divs, but I'm wondering if there is a better way of doing this, either with CSS Grid or Flexbox. The layout should look as is, and not use JS. https://codepen.io/anon/pen/GWzavX .o-container { margin: 0 auto; max-width: 1280px; } .o-grid { box-sizing: border-box; display: grid; grid-gap: 1rem; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, 1fr); max-width: 100%;

Make grid item use remaining space like flex item with flex-grow: 1 [duplicate]

☆樱花仙子☆ 提交于 2019-12-08 07:22:47
问题 This question already has answers here : Aligning grid items across the entire row/column (like flex items can) (2 answers) Closed last year . In a flexbox I can specify flex-grow:1 on a child to say it should take up the remaining space. html, body { height: 100% } <div style="display:flex;flex-direction:column;height:100%"> <div style="background-color:yellow;height:50px"></div> <div style="background-color:red;flex-grow:1"></div> </div> Is it possible to do the same thing with css grid? i

CSS Grid: dynamically span the last column

霸气de小男生 提交于 2019-12-07 22:37:59
问题 Is it possible to automatically span the last column to occupy the remaining space in the grid? Basically I'm trying to achieve this: .row { display: grid; grid-template-columns: repeat(3, 1fr); } .col { background: blue; padding: 20px; border: 1px solid red; } .col:last-child { background: yellow; /* missing magic here */ } <div class="row"> <div class="col"></div> <div class="col"></div> <div class="col"></div> </div> <div class="row"> <div class="col"></div> <div class="col"></div> </div>

Prevent grid area from expanding causing whole page to scroll

旧城冷巷雨未停 提交于 2019-12-07 15:50:23
问题 I'm using the following grid layout: grid-template-columns: 10em 1fr 10em; grid-template-rows: 2em 1fr 2em; To create a centered area that fills most of the screen while leaving some padding around it. Inside this 1fr x 1fr grid area is a pane div which contains an editor div which contains a content div. The content div can be any height, and the editor div has overflow: scroll set. My problem is that instead of pane staying the same size and editor handling the overflow, pane grows and

Fluidly scaling items in CSS Grid layout

断了今生、忘了曾经 提交于 2019-12-07 07:52:28
I've created a layout below using display: grid , I've used the old padding-top trick to have fluid square divs, but I'm wondering if there is a better way of doing this, either with CSS Grid or Flexbox. The layout should look as is, and not use JS. https://codepen.io/anon/pen/GWzavX .o-container { margin: 0 auto; max-width: 1280px; } .o-grid { box-sizing: border-box; display: grid; grid-gap: 1rem; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, 1fr); max-width: 100%; padding: 0 1rem; width: 100%; } .o-grid__content { box-sizing: border-box; height: 100%; padding: 1rem;

Creating overlay in CSS-Grid

◇◆丶佛笑我妖孽 提交于 2019-12-07 06:27:13
问题 I am trying to create an overlay in CSS3 grid but I can't seem to figure out how I can go about achieving it. I have searched online but haven't found anything of help. I want to achieve something like below: body { margin: 0; padding: 0; } .wrapper { display: grid; grid-template-rows: 1f; width: 100vw; height: 100vh; grid-template-areas: "a" "b" "c"; } .box { background-color: #444; color: #fff; } .a { grid-area: a; } .b { grid-area: b; } .c { grid-area: c; } <div class="wrapper"> <div class

Two-column layout with ability to reorder items without JavaScript

和自甴很熟 提交于 2019-12-07 05:30:13
问题 Is there a way to get 2 column layout that is transformed to a 1 column layout with a media query? Conditions for 2 column layout: items should flow one after another within columns items within columns will have different heights item position (order) can be imposed by html markup element position Conditions for 1 column layout: items should flow one after another items within columns will have different heights item position (!) cannot be imposed by html markup (should be controlled over

Large first item with a flexbox layout?

旧街凉风 提交于 2019-12-07 02:12:00
问题 I have a layout consisting of a single ordered list containing a bunch of items. All items have consistent width and height - except the first item - which is (3x) wider and (2x) taller. It looks like this: ol { padding:0; margin:0; min-width: 488px; } li { list-style: none; width: 150px; padding-bottom: 16.66%; border: 5px solid tomato; display: inline-block; } li:first-child { float:left; width: 478px; border-color: green; padding-bottom: 34.25%; margin: 0 4px 4px 0; } <ol> <li></li> <li><