V
17
c/coding-for-beginnersrichard_young80richard_young807d agoProlific Poster

Finally got my first CSS layout to actually line up after 3 days of fighting it

I've been learning HTML and CSS for about two months now, and I swear I spent all of last weekend trying to get a simple two-column layout to behave. Every time I added a padding or margin, the whole thing would jump to a new line or overlap with the footer. I'm talking maybe 60 tries at different flexbox properties before I realized I was using the wrong box-sizing value the whole time. It was literally just setting it to border-box that fixed everything in under 5 minutes. I felt like such a dummy but also super pumped that it finally worked. Has anyone else had a simple fix like that that took you way too long to figure out?
3 comments

Log in to join the discussion

Log In
3 Comments
noahgreen
noahgreen7d ago
Man did you ever figure out why your nav was doing that? I had a buddy who spent like four days trying to get his header to stay at the top of the page and it turned out he was missing a closing bracket on his CSS somewhere. He literally started over from scratch before he noticed it. Sometimes those tiny little things make you feel so dumb but also super relieved when you finally find em.
4
fiona_kim97
The border-box thing got me too lol, I think everyone hits that wall at some point and it feels so obvious after. @noahgreen is totally right about the closing bracket thing too, I've caught myself scrolling past a missing brace for way too long. Congrats on getting that layout to work, that first win feels so good after struggling for days.
2
paige166
paige1667d agoTop Commenter
Wait did you try setting display to flex on the parent container? I spent two hours once trying to figure out why my nav menu wouldn't stay inline and it turned out I had a stray closing div tag lol.
0