In this blog post I'm going to be taking your through my methods on how I got my main content area to look how it does.
In the screenshot above you can see how I've displayed my content, a simple 2 x 2 Grid, but to get to this point, it took a lot of work.
Initially I tried numerous methods of displaying my content, huge 100% elements that take up the entire browser but I felt this was too over powering and didn't match the layout of my work thus far, so I looked online for good ways to display content and I tried to get some inspiration, I came across this:
FlexBox - This is a brilliant tutorial and so in-depth, it goes through everything that the flex box is capable of. It then has the code you can copy which has the place holders which look like this:
These are the place holders and they stack when resized to this:
And then stacks down into 2 x 3 which is what I wanted, so from the code below I just removed the li class 5 and 6 as I only needed four for each of my topics, mammals, amphibians and reptiles, birds and trees.
Before
After
Here you can see my HTML elaborated from the previous one, where I've added my own content and titles, I've also applied my own div classes to each of the topics, so I could then target the paragraph within without influencing every paragraph in the website. I also used it to wrap the size of the text to a maximum of the same width as the images I used. You will also notice at the top of the screenshot I put the flex container, inside
another container as when the screen was big enough my content was going 3 images along and 1 below and it just wasn't consistent. So by putting it another container it restricted the flex container keeping a constant 2x2 until you went down to mobile size where it would become 4x1.
Here's my CSS for the flex boxes:
At the top of the screenshot you can see the container of the flex that I added, I gave it a width of 100% and a simple white background colour, I then added the position of relative so it could be influenced by the z-index (so scroll hint didn't show through)
Next is the flex container, this CSS was part of the code from the website I linked earlier, I simply changed the background colour and added a max-width. I did this so the elements would stack 2 on 2.
Just below that you can see the flex item, now I only included the no.1 as they are all the same with just different background urls. For this I changed the height to 200px and made the margin top 80px (from 10px) to increase the distance between the grey content intro, and the edge of the containerofflex div.
I then added a background URL code which changed the background to an image of choice from the default red one. After I'd done this I felt it needed a bit of 'lifting' so I found this tutorial on how to give a box-shadow that was subtle. -webkit-box-shadow: 0 1px 2px rgba (142,110,132,0.3); is that line of code for that, it basically says give the left and right sides of the container a 1px grey, 30% transparent border and the bottom a 2px one. This is the result.
Like I said, its only a subtle difference but it give the surrounding of my image a slight lift and makes it look that little bit more professional.
The final piece of code that I used for the CSS3 flex boxes is a pseudo :hover command, this essentially is manual for the browser to read that when 'this' happens 'this' also happens, in this case, when you :hover over flex-item1 replace the background: url with this one, in my case the same image with a simple vignette over the top, giving the audience/user some feedback that they have selected this, and it does lead somewhere.
Here is the before and after result:
Before (:hover)
As you can see it adds a very subtle roll-over effect that is nice and simple and looks professional!
In terms of the process I went through to achieve the looks of the text, it was the same as I explained in my previous blog post.