css-grid | Starter Files + Solutions to my CSSGridio Course
kandi X-RAY | css-grid Summary
kandi X-RAY | css-grid Summary
Hey! These are the starter files and finished solutions. Grab the full course over at CSSGrid.io.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of css-grid
css-grid Key Features
css-grid Examples and Code Snippets
Community Discussions
Trending Discussions on css-grid
QUESTION
Currently, my form looks as I want it to on the desktop. Example below
However, when condensed down on mobile, the form fields appear way too tight together
How can I have better control over how the form fields appear (width) on mobile. Would this also be media queries, or is there something wrong in my code that is causing the form fields width to become too tight when on mobile?
...ANSWER
Answered 2022-Feb-24 at 04:56You can set a min-width
on your
Flex will shrink all the way down with the browser, and min-width
allows it still to shrink, but stop shrinking at a desired width.
QUESTION
I am looking to add padding between elements of my form, as currently they are tight together. How can I adjust my css? Nothing has seemed to work thus far.
I would like the forgotten password the same proportional distance away from the button, but the button and form fields need more space between them.
...ANSWER
Answered 2022-Feb-20 at 18:51Use this:
QUESTION
Form is currently two columns, making the UI look awkward given there are just two form fields. I'm looking to make the field just one column given there are only two fields. How can I adjust?
Believe it has something to do with display: flex; but every alternate option I try, does not seem to work
...ANSWER
Answered 2022-Feb-19 at 06:56Use class
instead of className
(unless you are using React). Also, you are using a CSS-grid
which is splitting it into two columns. Change grid
to flex
on form
and use a column flex-direction.
QUESTION
I have a classic "top navigation bar - sidebar - main content" CSS grid layout which is also responsive and on smaller screens the sections are re-arranged vertically. The grid is styled to stretch out to the entire viewport. The main area is vertically scrollable if the content is longer than the viewport, whereas the top and side navigation bars are "pinned" to their positions and can't get smaller than their content in either direction.
To achieve the vertical scrolling in the main area, I've set the max-height
property of the grid container to 100vh
, and set the overflow-y
property of the main
element to auto
. This max-height
property, however, seems to have an adverse side-effect on the grid: the content can vertically overflow the grid container once the viewport's height becomes smaller than the minimum needed space to display the top navigation bar and sidebar (that can't shrink below their content).
This is what it looks like, for example, on a smaller screen, where the grid cells are stacked on top of each other:
The yellow overlay on the picture above is the scrolled-out part, not visible in the browser window. The main area is at the bottom with zero height (plus the border) but this is okay, as the main
element is vertically scrollable and the grid row is set to have 1fr height. The black border is for the entire grid container. As the example shows, the sidebar and the main area is outside of the container.
The same thing on a larger screen, where the sidebar is moved to the left, looks like this:
What I would like to have, however, is that the grid cells don't overlap with the grid container but they are fully contained. That is, on a smaller screen with vertically stacked cells, this:
And on larger screens, with the sidebar on the left:
Can this be achieved using some modified version of the grid structure and CSS given below in the code snippet? So basically I would like to have a scrollable main area with top navigation bar and sidebar which can't shrink vertically below their minimum required height, and a grid container that doesn't overlap with its content. I'd like to avoid anything explicitly sized to a specific value (i.e. I would not like to use something like height: 120px
.
Note, that this is a follow-up question on my previous one but it's not the same because I now have the requirement of a scrollable main area.
...ANSWER
Answered 2022-Feb-17 at 04:15A colleague of mine suggested to use the overflow-y: auto
property on the grid container itself. While its effect is not exactly the same as I was looking for, it's very similar and it does prevent the sidebar content from overflowing the container. The only minor difference is that when the available space becomes smaller than the necessary minimum to display the content of the grid, it's the grid container that gets a vertical scroll bar instead of the viewport.
Below is the modified code snippet that demonstrates it.
QUESTION
ANSWER
Answered 2022-Feb-14 at 21:21your issue is with the "asd" areas.
They have the same name, but they are not next to each other.
You can fix it changing those area names.
QUESTION
I would like to have a grid layout on a page where the grid stretches out to the entire viewport, and the rows have a minimum height. The simplest example would be a grid with a single cell (see code snippet below).
The problem I am having is that when the height of the viewport is less than the defined minimum row-height, the row vertically overflows its container. With the added red and green borders in the below example it's visible that the row's height isn't going below the defined 500 pixels, but the grid-container is still sized to the viewport which is now shorter than 500 pixels.
If I remove the height
CSS attribute from the grid
class, the container doesn't shrink below its content, but it also doesn't fill out the vertical space when the viewport is taller than 500 pixels. Since I want the grid to fill the entire page, I need the height
CSS attribute. I've also added the min-height: fit-content
attribute which is supposed to prevent the used value of the height
property from becoming smaller than the value specified for min-height
but it doesn't work (not with the defined fit-content
value - it works as expected with an exact value, for example 300px
).
In a similar question the culprit was the percentage values used for the gaps, but in this case there is nothing relatively sized. Even if replace the grid-template-rows: minmax(500px, 1fr);
property with the fixed grid-template-rows: 500px;
, it still behaves the same way.
ANSWER
Answered 2022-Feb-05 at 08:28Something to know is that as soon as a min height of a row, or the combined height of multiple rows is grater than the height of the viewport, you would have a scroll. Beyond that, the snippet below I hope do what you are looking for. I added comments in the code.
QUESTION
I have a ul
which in total contains 11
items.
I'm using display: grid
in order to achieve a layout where the first column (of the two) contains 7
of the li
elements.
I've tried to follow the approach here, by using grid-template-areas
, but my left
li
's seem to overlap each other.
In short, I'm looking to have first column (left) with 7
items, and second column (right) with 4
.
Demo:
...ANSWER
Answered 2022-Jan-27 at 20:11You can do it like below:
QUESTION
I want to achieve a pretty simple layout using a css grid (not flexbox) :
Currently I have this (similar but with an unwanted empty white area):
My question is what is the missing part(s) in my exemple code to achieve the desired layout ?
The issue seems very similar to this question: How to make CSS Grid items take up remaining space?
And this one: How do you collapse unused row in a CSS grid?
I have a green div on the last row, this last row need to grow with the page height.
To do that the row template for this last row is set to 1fr
.
You can check the very simple code snippet below:
...ANSWER
Answered 2021-Dec-28 at 16:34It looks like the easiest solution for this would be a nested grid setup (not to be confused with subgrid). Move the .green-content
div outside of the .container
grid. Then set up the body
as a grid with two rows - the first with a height of 180px
and the second with a height of 1fr
. The 180-pixel row will serve as the parent to the .container
grid. Note that you could also use a different element besides the body
to serve as the parent grid if you don't want to use the entire page. The snippet below is a working example
QUESTION
The following script displays exactly the same on each side of the screen. What I am trying to discover is how to group one set of dl/dt/dd definitions to be left side as normal with the dd below the dt as multiple lines but another group that will show the dt/dd on the same single lines.
I cannot figure out how to create two different dt/dd displays for the same page.
If you execute the script with the dl/dt/dd section commented out and then a second time with it in you will see the effects I'm trying to achieve, but both the multiple line and single line displays occurring on the same page as the same display. I'm thinking that there must be a way to define the CSS statements to act differently at different places on the same page. Obviously I would not do the displays in a real project, the side-by-side display is for question demonstration purposes only. Is there a way to do this?
I tried creating a class with the modified dl/dt/dd statements and then be referenced as a class. That approach does not seem to work.
...ANSWER
Answered 2021-Dec-31 at 03:43Maybe I'm missing something, but it seems like you just need to set the dt/dd's as child elements of dl with the '>' character. Here's an example showing the two different version views:
QUESTION
I'm trying to separate children of a container div into left/right columns, with no vertical whitespace below or above the children items.
I'll explain the setup and provide a picture of the desired result, and then I’ll explain every solution I’ve tried and why each solution doesn’t seem to work.
The Setup
I have a container with children
.left
or .right
. Here's the code (I am bound to this HTML structure):
...ANSWER
Answered 2021-Dec-27 at 09:25If you are allowed to use a little JS (and I assume you are since one of your trials included a jquery library) you can calculate the vertical position of each element, position each element absolutely, and at the end set the height of container if its relative positioning is important.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install css-grid
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page