css-grid

Using CSS transitions in CSS Grid Layout

ε祈祈猫儿з 提交于 2019-11-27 01:56:05
I am trying to get my sticky header to have a transition effect so it eases in rather than just a snap movement. What am I doing wrong? Here's my a working version: http://codepen.io/juanmata/pen/RVMbmr Basically the following code adds the class tiny to my wrapper class, this works fine. $(window).on('load', function() { $(window).on("scroll touchmove", function () { $('.wrapper').toggleClass('tiny', $(document).scrollTop() > 0); }); }); Here's the CSS part: .wrapper { grid-template-rows: 80px calc(75vh - 80px) 25vh 80px; -o-transition: all 0.5s; -moz-transition: all 0.5s; -webkit-transition:

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

◇◆丶佛笑我妖孽 提交于 2019-11-27 00:31:14
问题 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;

Preventing double borders in CSS Grid

雨燕双飞 提交于 2019-11-26 23:10:26
Given the current CSS grid example, how can I collapse the borders in order to avoid the double borders ? This is such a simple thing to achieve using an Html table. How do I do it using display: grid ? .wrapper { display: grid; grid-template-columns: 50px 50px 50px 50px; } .wrapper > div { padding: 15px; text-align: center; border: 1px solid black; } <div class="wrapper"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> <div>6</div> <div>7</div> <div>8</div> </div> You may do like this : .wrapper { display: inline-grid; grid-template-columns: 50px 50px 50px 50px; border-bottom

CSS only solution to set MULTIPLE “same height” row sections on a responsive grid

左心房为你撑大大i 提交于 2019-11-26 23:03:48
Wanted : a CSS only solution to enable MULTIPLE equal height grid "sections" on a per row basis, that is also responsive. Note: this is a follow-up question to this question which has only a single "equal height" section per item - which can be achieved through flexbox The below diagram should help explain the requirement: The "item grid" should be responsive - in that it can show a different number of cards per row based on viewport width (4 on desktop, 2 on mobile). Within a given row, the equivalent "content" and "feature" sections should have the same height. In the below HTML & CSS - the

CSS Grid unwanted column added automatically

不问归期 提交于 2019-11-26 21:54:27
问题 Trying to group items in two separate line by CSS Grid using different class names. It works fine until in "red" group have no more elements then predefined rows (this case 3). Can I somehow put the 4th "red" element in new row? If there is only 3 "red" element, everything works fine. ul { display: grid; grid-template-columns: 1fr 1fr 1fr; } .blue { background-color: blue; } .red { background-color: red; grid-row-start: 5; } <ul> <li class="blue"> <h2>1</h2> </li> <li class="red"> <h2>2</h2>

What is the purpose of flex-start and flex-end on justify-items?

寵の児 提交于 2019-11-26 21:46:23
问题 From what I know, justify-items is used only in CSS Grid , but there are the values of flex-start and flex-end . For which cases they are used? Mozilla developer - justify-items 回答1: This is an error. The justify-items and justify-self properties do not apply in flexbox. Consider your source of information: MDN Web Docs (formerly Mozilla Developer Network). This resource, although normally useful and reliable, nonetheless represents second hand information . The CSS definitions on MDN pages

Make flex items have equal width in a row

梦想的初衷 提交于 2019-11-26 21:45:47
问题 If you look at the example below, I want the headers ( h4.child-title ) to have the same length within the parent container. But I'm not successful in achieving this. Any help is appreciated. .top-level { display: flex; flex-flow: row wrap; } .section { display: flex; flex-flow: row nowrap; border: 1px solid; margin-right: 12px; margin-top: 12px; } .section-child { display: flex; flex-flow: column nowrap; align-items: center; flex: 1 1 0; } .child-title { white-space: nowrap; } .vertical

What are the areas covered by Flexbox which are difficult or impossible to achieve with Grid?

☆樱花仙子☆ 提交于 2019-11-26 19:10:18
It is wildly highlighted that Flexbox is for 1-D and Grid for 2-D but I have not found a clear explanation why Grid could not be used for 1-D and replace Flexbox. The closest I came to is But you could also argue that purely 1D layout like this is more powerful in Flexbox, because Flexbox allows us to move those elements around easier (e.g. move them all to one side or another, change their order, space them out evenly, etc). I use Grid and Flexbox for basic layout: a general placement of the boxes on the page and some dynamic ones, usually stacked. The esthetical ones (toasters, modals, ...)

Grid gap percentage without height

纵然是瞬间 提交于 2019-11-26 18:36:04
问题 I'd like to have a grid like this: .grid{ display:grid; grid-gap:50%; background-color:blue; } .grid-1{ background-color:red; } <div class="grid"> <div class="grid-1"> test </div> <div class="grid-1"> test </div> <div class="grid-1"> test </div> </div> I think it's a really big problem by all browser to correctly understand percentage values How to resolve this? Markus 回答1: Initially, we cannot resolve the percentage of the grid-gap since it depends on the height so we ignore it (we consider

A grid layout with responsive squares

不打扰是莪最后的温柔 提交于 2019-11-26 17:57:29
I am wanting to create a grid layout with responsive squares. I feel like I should be able to do this with CSS Grid layout but having trouble setting the height of each square to be equal to the width. Also having trouble setting a gutter between each square. Would I be better off using flexbox? Currently my HTML looks like this but will be dynamic so more squares may be added. And of course it needs to be responsive so will ideally use a media query to collapse it to one column. <div class="square-container"> <div class="square"> <div class="content"> </div> </div> <div class="square"> <div