Simplifying Life with CSS Frameworks
Responsive Design, Mobile First, Material Design, UX, IxD...You can choke on technology. It's coming fast and furiously. The biggest challenge of the 21st century may be how to simplify life. How to do one thing at a time when you have five LCD screens blinking at you all the time each with multiple notifications, announcements, ticker tapes, breaking news and all the rest of it.
I can't solve all your life's problems but can share a little trick or two here and there. If you gather all these tricks, you could actually simplify life.
Mobile FirstThis is a recent approach to website design. In Kenya 97% of web users use their mobiles. Few have computers, many have smartphones. Therefore, why make websites for computers when these are the minority? Why not make them for mobile first and adjust to fit the few who visit with computers.
The chart below shows the data from Google Barometer for Kenya:
Mobile access is at 97% compared to 17% for computers.
One of the ways to handle this task of creating web pages for everyone is to use CSS (Cascading Style Sheets) frameworks or libraries. If you ask web developers what are the best CSS frameworks, you are likely to get a list such as the following:
- Materialize CSS
- Semantic UI
The site was a placeholder page for a new savings cooperative called Mhadhiri. The nightmare was that the logo on the home page displayed well in a PC screen but overflowed a smartphone screen. If you look for solutions online, you will see discussions about the CSS @media directive. The idea is to tell the browser:
- For devices with small screens, display the logo using this size
- For devices with medium screens, use this other size
- For devices with large screens, use the full size logo etc.
The logo was inserted using a standard <img > tag. Some of the traditional responsive code looks like this (click to enlarge):
But it did not work. The mobile still displayed a huge logo while the computer displayed a logo that was acceptable. What to do?
It turns out that W3.CSS has (simple) tools to handle this kind of thing. You can specify whether to display or not display some content depending on the screen size of the device used to access the web site. Examples (actually used in Mhadhiri):
class="w3-hide-medium" applies a directive that means "do not show this item in medium-sized devices". What constitutes medium is defined by break points which are the screen sizes in pixels that define the boundaries as you move from one size to another. Google's Material Design recommends the following break points: 480, 600, 840, 960, 1280, 1440, and 1600dp. A dp (device-independent pixel) is related to a pixel though they are not identical.
In the code above, the logo file is called "Mhadhiri SACCO.jpg". In the first segment, the W3.CSS class directive says: w3-hide-large w3-hide-medium. There are only three categories: small, medium and large. It means this logo, set to display with a width of 320px, will not display in a medium and large screen but will display in a small screen.
The second segment of code will display the logo at 450px only in a medium screen while the last will display only in a large screen at 1000px. W3.CSS uses the break points 0 - 600 for small, 601 - 991 for medium and 992+ for large.
In summary, the Mobile First web design philosophy takes the view that it is better to design for mobile access first then adjust for PC access simply because the majority of web users now access the web principally via mobile. In designing for such a scenario, responsive designs become mandatory. CSS frameworks provide a way to implement responsiveness without getting into complex code. It is analogous to the debate of declarative versus procedural programming that programming theorists sometimes engage in. The truth is that few want to get into complex code if a few libraries and APIs offer an easier, quicker and more elegant way to do the job. In conclusion, after messing around with CSS for quite some time, it did not work. But a couple of W.CSS directives did the job in less than a minute. The moral of the story: Simplify your life. John the Baptist had only one suit. He never ate a cooked meal. Yet he ushered in the Messiah. Simplify.
And finally, I must tell you that this same John the Baptist, this same Elijah, is here crying again in the wilderness: The Messiah is coming! Prepare the way.
Be most blessed today.