CSS-Grid has had an enormous impact on my workflow and the possibilities when designing for the web.
To create a variety of fall-back support for a CSS Grid website without having a negative impact on the design on modern browsers. The aim is to provide as close an experience as possible.
At this point, only the latest browsers are supporting grid it is important to consider how to offer some form of support for users on older browsers. In this article I discuss various techniques that can be used to offer fall-back support for CSS-Grid layouts.
I started by created a basic grid layout, placing it into a @supports rule. This isn’t strictly necessary since as Rachel Andrew points out, browsers will ignore CSS they don’t understand. However, I intended on utilising some of the features of CSS-Grid to style my grid in ways I wouldn’t be able to within the fall-back solutions.
Once the basic grid was set up I took any CSS which would be relevant for my fall-back styles and placed them above my existing ones. The browser will always use the last property (it understands) within the CSS file when styling the page, so at this point I began styling the page as closely as possible to the original, this time in flex-box. It is important here however to reset any values used for the fall-back within the @supports (display: grid) rule so the designs don’t conflict with one another.
Another advantage of putting all the grid styles within a supports rule is the ease in testing your fall-back solutions. You can quickly comment out the whole rule to see your design reset to flex-box.
Whilst the flex-box backup does allow users on slightly older browsers some form of experience on the page, it doesn’t support the complexity of page grid I created without adding more div elements to the page to style it further. This wasn’t an option for me as it would make my primary grid less responsive.
That’ all well and good, but flex-box itself is a relative newcomer, meaning it only offers limited support and won’t help with older browsers. This is where the final fall-back comes in: floats. Setting all the grid boxes to float left won’t have any negative impact on the default template but will allow older pages to render a simple version of the grid.
In addition to support for the grid itself I added fall-back background colours where I have used transparency so on older browsers text will still be legible. To ensure everything works smoothly on Internet Explorer 8 and earlier I implemented Sjoerd Visscher’s HTML5Shiv which teaches older browsers how to use HTML5, most importantly creating elements for <header> <main> and <footer>.
Pass: This is the main grid layout, working as intended
Pass: Flex-box backup running as intended with simpler grid
Pass: Float fall-back working as intended with simpler grid
Fail: positioning isn’t working, article text has been lost, footer has floated next to the grid
Overall there is some reasonable fall-back support implemented here, however more could be done to ensure the layout performs across a wider range of browsers. The question is ultimately how much support is required for each individual project? If the answer is IE6+, is it worth using Grid in the first place?
As this was my first time developing a website with grid I wanted to be sure that I implemented it as efficiently as possible. To do this I first structured my homepage wireframes to the grid specification and began applying styles. My first attempt was scruffy at best and was particularly difficult to edit. To rectify this, I took the knowledge I had gained with my first attempt and began redeveloping the homepage in a much cleaner fashion with more focus on coding in such a way that it would be easier to implement design changes in future. This meant creating more reusable classes that could be used to quickly change colours and styles across the website quickly rather than having to change each element individually.
In order to reduce the size of the homepage and speed up loading times I seperated styles which are specific to project pages into another file meaning they aren’t being downloaded unnecessarily. Once the user clicks through to a project page the main styles should already be cached and the browser should only need to download the page specific styles and images.
One of the inspirations for my portfolio is my love of Netflix’s Stranger Things and 1980’s “retrowave” design. In fact the idea to create the neon-like headings on the website came from my attempt at creating the Stranger Things opening titles in CSS. To achieve this effect I created a simple webkit keyframe animation, quickly changing the text colour to a darker shade and giving each character in the heading a different timer in order to create a realistic neon-flicker. To make the effect more convincing I then made the text-shadow disappear when the character flickers to give the illusion that there is light flickering on and off.
The most significant impact on page size and loading times on my website is the images. To make the website more mobile friendly and reduce loading times I have optimized the images, increasing file compression as much as possible without subtracting from the perceived quality of the images on the website itself. In addition to this I have exported the images scaled to their relative max sizes on screen which drastically lowers file sizes.
Image scaling is particularly important where I have used images with transparency such as my logo as PNG graphics are typically larger in size than their JPEG equivalent. I have made any images which do not require transparency in JPEG format for this very reason.
The majority of search engine optimization is dictated by the quality of the content on the website itself. I have attempted to create keyword rich content and blogs with a relevance to front end web development.
In addition to the content, as of April 2015, Google decided to “use mobile friendliness as a ranking signal”. To test whether or not my website confirms to Google’s specification of a mobile friendly website I ran their Mobile Friendly Test which confirmed the website was indeed mobile friendly.
Finally, I have included relevant metadata to my portfolio using relevant keywords and page descriptions.
Have a project in mind? Feel free to get in touch using the contact form and I'll be happy to help. Alternatively, you can email me directly at email@example.com.