css-grid

Sticky header on css grid

别等时光非礼了梦想. 提交于 2019-12-05 06:37:13
I've got a nifty responsive css template using css grids and I'd like to make the header of this responsive css grid sticky, but because of the way the header and nav is designed, I can't get it to use fixed positioning. is there a better way of doing this with some grid property I might not have seen yet? * { margin: 0; padding: 0; } body { display: grid; font-family: sans-serif; } a { text-decoration: none; color: white; } header, nav { background: blue; color: #fff; position: fixed; } nav { display: flex; flex-wrap: wrap; align-items: center; } nav span { margin-right: auto; } header {

Can I have a varying number of columns per row in a CSS grid?

烈酒焚心 提交于 2019-12-05 03:12:40
.grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: 100px; grid-auto-rows: 60px; grid-gap: 15px; } .col { background-color: tomato; } <div class="grid"> <div class="col"></div> <div class="col"></div> <div class="col"></div> <div class="col"></div> <div class="col"></div> </div> This creates 2 rows, first is 100px height, second is auto-created with 60px height. 2 columns in the second row have 1fr width. Is this possible via CSS Grid/Flexbox to horizontally center 2 columns in the 2nd row? I.e. have a varying number of columns per row. I am stuck trying to solve

Responsive CSS Grid layout with position: fixed

自作多情 提交于 2019-12-05 01:11:00
I'm building a responsive template with CSS Grid Layout (still learning) and thanks to a few of you on here, I've got most of it working. mobile (max-width: 767px) everything should appear on its own row tablet (min-width: 768px) nav is on the first row aside and main on the second desktop (min-width: 992px) same as tablet but with 10% of spacing horizontally xl desktop (min-width: 1920px) same as desktop but has a max-width of 1920px The thing is I'm using a header tag to color the spacing to the left and right of the nav . Whether I use a header or a div, it doesn't seem right having an

How can I control the number of items per column in flexbox?

 ̄綄美尐妖づ 提交于 2019-12-04 08:30:45
In a flex container I have 5 items with a column direction but in a certain width I want to display 3 per column and force the others to wrap is there any way to do that without fixed height ? my code : <div class="container"> <div class="item-1 item">Item 1</div> <div class="item-2 item">Item 2</div> <div class="item-3 item">Item 3</div> <div class="item-4 item">Item 4</div> <div class="item-5 item">Item 5</div> </div> .container { display: flex; flex-flow: column wrap; } @media (min-width: 30em) { } js Bin: http://jsbin.com/fesujifelu/edit?html,css,output In flexbox, items need a height /

Equal height different aspect ratio boxes with CSS grid

醉酒当歌 提交于 2019-12-04 07:53:43
I'm trying to create layout like this: Orange blocks on the right side all have the same aspect ratio and thus height. Blue block has different aspect ratio. Height of blue block and summ of orange blocks should be equal, as shown on the image. Is there a way to create such layout via CSS grid? I know that I can wrap orange items in a separate column element, but I'd like to avoid this. I also managed to create this layout when aspect ratio of each item is square, but no luck with this one... Example on jsfiddle http://jsfiddle.net/fq974gov/ .grid { display: grid; grid-gap: 10px; width: 200px;

CSS: display: grid and/or -ms-grid

谁说我不能喝 提交于 2019-12-04 07:50:22
问题 Is there a way to use both or either display: grid/-ms-grid into one style sheet or do I have to use an HTML hack or JavaScript to query what type of browser a page is being viewed with grid layout? Example: The following styling doesn't seem to work .container { display: grid -ms-grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(150px, 50px); grid-gap: 1vw; -ms-grid-columns: repeat(4, 1fr); -ms-grid-rows: repeat(150px, 50px); -ms-grid-gap: 1vw; } 回答1: Transforming new

Forcing a column to be empty in a responsive grid layout

扶醉桌前 提交于 2019-12-04 06:48:59
问题 I've a grid of items and the first item spans rows 1 and 2 (for a menu). I'd like to keep the grid under this area empty, but because I don't know how many items will be displayed I'm using auto-fit and as the page reflows this area is filled. I guess I could make a wrapper with display flex and then split the search element from the grid items, but I'd be interested in knowing how to force certain areas to be empty when the grid is responsive. I'd say there's a 95% chance I'm doing something

Trying to add an image inside a CSS Grid

允我心安 提交于 2019-12-04 06:26:01
问题 How would I be able to put an image inside a CSS Grid? This is all I'm trying to do and can't figure it out. This was my attempt at a CSS Grid: https://jsfiddle.net/g6oaht8f/72/ But it didn’t work as I had expected it would. The grid isn’t viewable over the image here. If the grid was viewable the lines would be Red . Full Code: https://jsfiddle.net/g6oaht8f/73/ .wrap { position: relative; width: 600px; height: 600px; margin-top: 45px; overflow: hidden; border-radius: 25px; background: url(

Change the column order in a css grid

≯℡__Kan透↙ 提交于 2019-12-04 06:22:06
I am playing around with CSS grids. When I view it on a desktop size (min-width: 769px) I have a single row with 3 columns - something like this: --------------------------------------------- | col 1 | col 2 | col 3 | | | | | --------------------------------------------- Can I with css-grid move the columns around so I can do something like this on a mobile layout: --------------------------------------------- | col 1 | col 3 | | | | --------------------------------------------- | col 2 | --------------------------------------------- I know I span cells with something like this: .content{ grid

CSS Grid not working in ie11 despite prefixes

牧云@^-^@ 提交于 2019-12-04 05:43:35
问题 I have the following simple layout example using CSS grid .container { width: 100%; display: -ms-grid; display: grid; -ms-grid-columns: 1fr auto 1fr; grid-template-columns: 1fr auto 1fr; } .item1 { text-align:center; background:red; color:white; padding:20px } .item2 { text-align:center; background:green; color:white; padding:20px } .item3 { text-align:center; background:blue; color:white; padding:20px } <div class="container"> <div class="item1"> Item 1 </div> <div class="item2"> Item 2 <