My CSS Learnings During Pragmint Apprenticeship
Trial and error only gets you so far. Sometimes the fastest path forward is take a step back and hit the books. Here are my Pragmint apprenticeship experiences with having to slow down and skill up my CSS skills.
November 9, 2021
4 min read

Prior to my apprenticeship at Pragmint, I found working with CSS to be a game of trial and error. Much like the CSS meme of Peter trying to open the blinds. Trial and error isn’t necessarily bad, but, it could be a red flag that you don’t know the material well enough. In my case, I still had gaps in understanding how css properties behaved.

My first CSS project at the apprenticeship was to style the Speed Tic Tac Toe game per the provided Figma UI design. The in-browser game also needed to have responsive layout and look appropriate on mobile devices. The first challenge was to get a Tic Tac Toe board that showed an “X” image in all available spots on screen. The layout would involve stacking elements on top of each other so, with that knowledge, I began poking away at the CSS. It wasn’t long until I noticed I was stuck in a loop, aimlessly change some property and hope it would produce the result I wanted. It became clear to me that I didn’t fully understand the CSS properties I was using. Admitting this to myself was the best thing that I could do. Perhaps, I would have gotten lucky and entered a css property(s) that would have styled the webpage as desired. However, why work in the dark when I could use this situation as a learning opportunity? With some encouragement from my mentor, Dave, I headed to W3Schools to read up on the material. I quickly learned I needed to set the parent element’s position property to relative before a child's “property: absolute” would take effect. Boom, what a time saver and lesson for how to approach CSS problems!
The next Speed Tic Tac Toe styling challenge was to add 2 more Tic Tac Toe boards to the screen, so that 3 boards showed from left to right. In addition, the UI needed to switch from a left/right stack to a top/bottom stack when viewed on mobile device screen sizes. If you were wondering why 3 boards, Speed Tic Tac Toe is a 3D game and has a top board, middle board, and bottom board. I began by looking at the W3 Schools CSS documentation and found the display property, flex. This was perfect because I could add a media query for mobile screen sizes and simply change the flex-direction to be column instead of row. From here, implementation was straight forward.
The second CSS project at the apprenticeship was to style the Pragmint Website per the provided Figma UI design. This project required much more CSS than the Speed Tic Tac Toe Project. First, I reviewed the Figma. I identified common elements that showed up from section to section. For example, forms, text, titles, section dimensions, etc. all looked very similar among sections. Then, I identified section specific styles and sections with minor deviation from a commonly used style. From this information, I knew I was going to create 2 conceptual levels for style. One for commonly used elements and the other for any specific section. By the end of the project, I had a CSS file for each common component, like forms, navbar, and the text on left/image on right components. Then, I had a CSS file for each specific section that required unique styling, deviations, or overrides. This organization technique resulted in many small css files making the existing CSS easy to understand and change, which has proved to be very beneficial.
The Pragmint Website also required a responsive layout. From referencing other websites, I learned that a max width for each section is needed. For example, allow a section width of 100% until the screen width exceeds 1300px. Then set the section width to equal 1300px. This kept the content from stretching beyond 1300px on very wide screen sizes. On the contrary, smaller screen sizes and mobile obviously can’t fit the same content as larger screen sizes. Display flex, float none, and display none can all be used to display content from top/bottom or to hide less important content when the screen size is small. In addition, relative units like the vw unit were effective for relative sizing on small mobile devices, where screen widths are very small.
Overall, I’ve learned that its often quicker and better for the long run to look up information in official documentation than it is to guess. I’ve learned that best practices like the single responsibility principle and smaller structures can be used when styling CSS. They help organize the otherwise messy lists of css class declarations. Plus, smaller CSS classes can be used in a modular way to create unique element styles.
Based on my experiences from my apprenticeship at Pragmint. https://pragmint.com/