Positioning containers inside a flex container, using the "middle portion of the page"

Really poorly illustrated but I'm effectively trying to accomplish this. My portfolio (https://www.callum-laing.com/) is one of those where I'm not fully utilizing the entire width of the page. Something I've always struggled with, and hoped that learning grid would maybe help with, is trying to have my Contact section split like the image I've attached. I did attempt grid-areas but that just ended up with the form on the far-left side of the page, and the socials right next to it. Flex is probably my best bet but I'm not really sure how to go about handling coding it. Ignore the mess, I've just copy pasta'd my portfolio code into a codepen, scroll to the bottom for container section šŸ˜„ https://codepen.io/pen/
CodePen
...
49 Replies
b1mind
b1mindā€¢17mo ago
So you have lots of control either way. Cause I like that you tried grid areas here is just one way you could do it. Lots depends on how you want the children to behave responsively. Also do you want them to be dense or fill the avail space at any points.
CDL
CDLOPā€¢17mo ago
I only really have github + linkedin to go on the right side, so I guess it's going to need to fill a decent-ish amount of space (large svg/text I guess). For the time being though I just want it to really look kinda like how I have my hero page.
CDL
CDLOPā€¢17mo ago
Also seem to be having trouble trying to center my damn button xD (would also say, the non-clicked button color seems kinda shitty huh?)
b1mind
b1mindā€¢17mo ago
errr forgot to save there we go lol
CDL
CDLOPā€¢17mo ago
iiiiiiiiiinteresting I imagine for this to work I'm going to need to remove the flexbox I have on the section container, right?
b1mind
b1mindā€¢17mo ago
I didn't see your pen cause you didn't link it right
b1mind
b1mindā€¢17mo ago
I would put it on the section and not have the extra div You don't have to give the area to the following divs cause they will just fall in place but the first div will need the title name grid-area: title;
CDL
CDLOPā€¢17mo ago
Ah, yea sorry forgot I even had that div. Ok that looks a bit better contact form is huge on a fullsized monitor, but I'm not sure I can do much about that
b1mind
b1mindā€¢17mo ago
always can do something.. Add a break point where you think its too big or just a max-width on the element or control it with the grid-template-cols you got options .contactContainer { max-width: 600px; works well
CDL
CDLOPā€¢17mo ago
I think that looks better.. did some tweaks the background on the contact form looked a little odd, removed it Thanks b1 šŸ™‚
b1mind
b1mindā€¢17mo ago
glad I could help, had me at grid areas xD
CDL
CDLOPā€¢17mo ago
Really love grid now I've learned it lol
b1mind
b1mindā€¢17mo ago
Also I love this kinda template for cards too. and auto 1fr is great for titles/body
CDL
CDLOPā€¢17mo ago
yeah my project cards section is gridded up
b1mind
b1mindā€¢17mo ago
auto 1fr auto great for header/body/footer too body grows head/foot stay the same size xD (or rather stay "dense")
CDL
CDLOPā€¢17mo ago
Oh oh I found an issue with this D:
b1mind
b1mindā€¢17mo ago
learning to fool with when to justify/align/place with content and items is key too
CDL
CDLOPā€¢17mo ago
So I took the contact section out of the flexbox I had setup originally
CDL
CDLOPā€¢17mo ago
so weirdly now my projects section looks like this
b1mind
b1mindā€¢17mo ago
self will make things dense is a good gotcha too
CDL
CDLOPā€¢17mo ago
yeah tbh I didn't even know place-self was a thing
b1mind
b1mindā€¢17mo ago
you can in flex box too šŸ˜‰ nice when you want a child to miss behave from parents placement I'll use it lots when layering too https://codepen.io/b1mind/pen/jOQYXrP plop a absolute on a grid child too and you can abuse self place-self: end vs bottom/right: 0; (and can be more responsive when you need it) šŸ˜‰
CDL
CDLOPā€¢17mo ago
making notes of this šŸ˜‚ I fixed the projects bit all I need to do now is uhh.. bring the height of contact me down a wee bit it's a little.... high
CDL
CDLOPā€¢17mo ago
CDL
CDLOPā€¢17mo ago
all that "white" space šŸ˜‚
b1mind
b1mindā€¢17mo ago
mmm your codepen not doing that xD did you forget template-rows: auto 1fr` as we were talking about it xD
CDL
CDLOPā€¢17mo ago
#contact {
padding: 1rem;
display: grid;
grid-template-rows: auto 1fr;
grid-template-areas:
"title title"
"form socials";
gap: 2rem;
place-items: center;
font-family: "Sen", "sans-serif";
font-weight: 600;
min-height: 100vh;
}
#contact {
padding: 1rem;
display: grid;
grid-template-rows: auto 1fr;
grid-template-areas:
"title title"
"form socials";
gap: 2rem;
place-items: center;
font-family: "Sen", "sans-serif";
font-weight: 600;
min-height: 100vh;
}
b1mind
b1mindā€¢17mo ago
This is one the things I love about grid. Is it will want to fill space by default so then its the other dives and center do justify-items: center; not place then they with default to align-items: start the min-height 100vh >.>;; hah so you are deff filling with that too
CDL
CDLOPā€¢17mo ago
yeah i'm not a fan of it 2 things I gotta work on. A) setting the view height and B) positioning where things should sit vertically on the page
CDL
CDLOPā€¢17mo ago
b1mind
b1mindā€¢17mo ago
I only use the 100% "hack" cause of mobile issues but yea it can be a pita sometimes to always fill haha
CDL
CDLOPā€¢17mo ago
'least it's filling lmao
b1mind
b1mindā€¢17mo ago
So if you want things to get dense you have options too Do what you do in flex to fill (but reverse lol)... and limit the height: fit/max-content; Or align-self: start; will make it go dense. or on parent I think align-content: start; ? err items lol content keeps growth xD
CDL
CDLOPā€¢17mo ago
I think because of how little I have on this page, it's probably a smarter idea to just center the form, and stick the links inside the form, but to the right of it
b1mind
b1mindā€¢17mo ago
I would just let the content determine height on this one give it spacing and brrr
CDL
CDLOPā€¢17mo ago
CDL
CDLOPā€¢17mo ago
designer career incoming
b1mind
b1mindā€¢17mo ago
ayo
CDL
CDLOPā€¢17mo ago
well it already is isnt it with auto 1fr on the rows?
b1mind
b1mindā€¢17mo ago
designers everywhere triggered
CDL
CDLOPā€¢17mo ago
ugh don't, I have such bad ocd, I've already fixed it on my mspaint
b1mind
b1mindā€¢17mo ago
I'm the son of a carpenter, plum and level eye šŸ¤£ least that is what I tell myself when I don't use guidelines One the things I love about figma is how it does the pos helpers So for the heading yes auto will make the content of the row dense not the items inside it. but the 1fr will fill avail space which you use 100vh and well yea lots of space xD but if you let the content decide height the 1fr will just expand to meet it that make sense? that is where minmax(200px, 1fr) and stuff comes in real handy too cause you can set a min height and max out 1fr to always grow
CDL
CDLOPā€¢17mo ago
Yeah that makes sense I tried the flex version I mentioned and that is probably a better idea, considering how little content I have on the page at the moment
CDL
CDLOPā€¢17mo ago
CDL
CDLOPā€¢17mo ago
Aight we're done
CDL
CDLOPā€¢17mo ago
Thanks for the help b1!
Want results from more Discord servers?
Add your server