Category Archives: FREE stuff

Curtain Mobile Nav

Today’s Tidy Tutorial is going to look at a take on a mobile nav, showcasing a curtain style open and close animation with fading nav links.

We’ve got a couple of elements here that are pretty standard and won’t be covered but you can check the Pen to see these (mainly the nav toggles). Before we jump into the nitty-gritty let’s look at the setup…

A FREE Mobile Nav Tutorial

We’re going to need a HTML structure of the nav, it’s going to look a little like this:

There’s nothing out of the ordinary here, looking at the above code block it’s a pretty standard structure. The only item which could be considered an oddity is the toggle bars being the first nav item – this is purely for some automatically calculated spacing for the closing toggle. Now we just need some initial styling:

This first CSS block will place the nav above the page’s content when we’re ready to show it. Also you’ll see the comment above the ‘height’ declaration, we’re placing this here so we can style the nav. We will need to take this away to hide the nav, but first, before we completely hide the nav we need to write a quick fix to space out the close toggle bar properly and move onto some styling:

Nothing complex here, it just places the cross to the left and moves it into the centre of the li. The reason it originally seems out of line is due to the transforms moving the spans into the cross shape. To see how we’ve created to toggles please see the Codepen Pen of this tutorial.

Everything is quite squished right now, so we need to make the ul the same height as the nav and also space out the links:

Here we’re using the beauty of flex to automatically evenly space out the links, flex direction states we want the links in a column. If you’re unsure on any of the styles around flex then check this post from CSS Tricks, everything you’ll need to know will be covered:

Time to add in the curtain effects styles, we’re going to use pseudo elements. We’ll start by creating both and move the positioning of each after:

You’re going to see a rectangle now that takes up half of the page…

::before is our left “curtain”, ::after will be the right. We need to move the ::after pseudo element to the right side. We will do this with the following style:

Now your whole screen should be covered by the “curtains”. These need to be hidden off screen though so they can be animated in later:

Simple transforms are how we do this, adding a minus to the ::before’s style to move this to the left.

Now the majority of styles have been completed but before we move on we need to hide the nav when we don’t need it. A simple few lines will do this:

On our page we should just see the hamburger and whatever other content we’ve placed on the page, for us just a header:

Next we’re going to need to add the only JS side to this tutorial, a simple class added to the nav element will be what triggers the opening and closing of the nav. We just need one event listener which is going to toggle the class, it doesn’t get much simpler than this:

That’s the JS done, everything else is going to run through CSS. All the styles which deal with the open nav are going to be prefaced with ‘.nav-open’. Starting with these following few styles we make it so the mobile nav is able to be opened, the page once you click on the nav toggle will be covered by the “curtain” elements.

Two problems here though – first, we’re stuck here; we’ve not shown the links so you can’t go back. Second, the curtain elements jumped in rather than animated in. Let’s fix the latter first:

You can tweak this style however you like, the timings can make a big difference but the biggest impact can be made through the timing function, we’re using ease-out but play around with other standard timings and even try creating your own cubic bezier (here’s a great site for helping you create your own

This is where things get a little finicky, if you were to close the nav now you’ll see the whole thing instantly disappears. This is down to the measures taken to completely hide the nav when it’s not in use. To fix this we have to get creative with transitions:

Toggle between the open and closed state now and you’ll see the curtain elements open and close properly. Once the curtains move in we can tackle the links, currently they show and hide instantly, we want these to appear after the curtains have shown.

We’ll start by getting the nav links to show once the curtains have closed, to do this is pretty similar to the above, on the ‘.nav-item’ class we set the transition duration and delay. The delay needs to be set for longer than the curtains’ transition duration:

The reason we’re breaking out the transition declarations into their long form is so we can override them individually. Also as mentioned above, setting the delay on the nav-open class means we can provide different times for both the opening and closing sections of this transitions. We want the nav items to fade out first on the closing – to do this we’ll set the transition delay to 0 on the just the ‘.nav-item’ class:

We’re nearly there! We just need a few final tweaks. The first one to tackle is getting the curtains to transition out after the links have faded out. We need to add the delay onto the nav before and afters, also adding a delay to the nav-open before and after of 0s to keep the curtains opening first on the initial menu opening:

The very last bits run of the same ideas as the previous couple of CSS code blocks, we need to update the time on the nav elements’ transition duration to the total time of the closing transition. This is the nav pseudo elements’ transition duration (.5s) + nav links’ transition duration (.5s) + transition delay difference (.15) which equals 1.15s.

Finally let’s do the double transition timing trick to get the padding of the main nav to visible as soon as the nav opens and be removed once the links fade out – this stops a glitchy looking jump. The reason it’s added after is to help make the nav hide completely, if we were to use display none on the container then the children (nav items) would lose their ability to transition their opacity. The last code block is:

There we have it, a completed mobile curtain like navigation. There’re a few quirks of CSS to overcome along the way but the final product is worthy of that extra effort. Have a play around with the styles in the Pen and see what you can come up with!

Thank you for reading, we hope you enjoyed this FREE mobile nav tutorial, until next time!


Creating a Mobile Navigation

Today I’m going to give you a short tutorial on how to create a mobile navigation. This mobile navigation will slide in from the left side of the page. Here you will find everything you need to create the nav including how to animate the hamburger icon and the JavaScript needed to open and close the menu.

We will start with the html needed to create the menu:

The first step is to wrap the whole navigation in a ‘nav’ tag, this a new HTML5 tag which represents a section of code with the purpose of providing links. Next is the navigation toggle (the div which will be the trigger for opening and closing the nav), this will have a class of ‘nav-toggle’ and contain the hamburger icon to indicate where the user should click to open the menu. Three span elements will be placed into the ‘nav-toggle’ div, these will be used to create the hamburger bars. The main styling of these bars will be implemented using the ‘bar’ class and the positioning will be done through the ‘id’ assigned to them.

Finally we create a div with the class ‘nav’ that’ll hold the logo of the company as well as the ‘ul’ containing all the links needed. For now we will add a ‘#’ inside the ‘href’ as a placeholder, later this will be swapped for the url you’d like the link to direct to. This code will give you the very basic structure ready to be styled with CSS.

Moving on to the styling will start with the ‘nav toggle’. We want this to be set to ‘position: fixed’ so it follows us as we move down the page, if it wasn’t then the user would have to scroll up the page just to open the menu. Once the position is set to ‘fixed’ we can move the toggle to where we’d like it, I want mine to be sat at the top of the page to the left. Here is how:

If you’d like yours to sit to the right of the page swap ‘left: 10px’ for ‘right: 10px’.

Continuing the styling of the nav toggle we set a height and width of 40px along with a background colour. The colour we’re using in the tutorial is one which matches the clients colour scheme, but you can use any colour you choose. This will leave us with a small green square, we want our toggle to be a circle though so let’s add a border-radius of 50%. Add the following code to the previous block:

To finish of the main styles for the nav we will add a box-shadow to make it stand out from the page and a z-index so it stays above other elements on the page. Finally we need to set cursor to ‘pointer’, this changes the cursor on hover and without it iOS devices won’t trigger a JavaScript click event. Below is the complete css for ‘nav-toggle’ and how it should look in your browser:

Now we have the toggle styled we need to add the hamburger bars. This is a simple process as the ‘bar’ class has been added to all three necessary elements one block of code will style all three. The CSS is relatively straight forward. ‘Position’ needs to be set to ‘absolute’ so we can move them easily into place, and the ‘display’ set to ‘block’ so it can be given a height and width.

A nice trick here as they’re positioned absolute it to set the margin to auto and left and right to 0, this automatically centres them inside the nav toggle. Here are all the styles needed to make the hamburger bars.

If you were to refresh your page now you’d the nav toggle with one single bar at the very top, this is due to them currently set to the same position. All three bars are there they’re just sat on top of one another. This is where the ID’s come in, we need to target each bars ID and space them out evenly.

We can leave the nav toggle and return later when it comes to animating the hamburger ‘bars’.

Now for the navigation. We need the nav to stay on the side of page no matter how far the user has scrolled down, for this set the position of ‘.nav’ to fixed. Once the navigation is stuck to our scroll position it’s time to set the height and width. For the height a simple 100% is needed here for it to be the full height of the screen regardless of the device it’s viewed on. Width can be whatever you’d like, for the tutorial we’re going to use 230px. The starting code for the nav should look like this.

The final nav styles for now include a background colour which again is up to you what you choose, we will run with the colour scheme already in use and pick a lighter green that’s slightly transparent. The background colour style will be set to an rgba colour so we can specify the alpha, our is ‘rgba(126, 160, 97, .95)’. To make sure it always sits on top of the page elements a z-index of 5 needs to be set. The complete nav styles so far are:

Next is a very simple setup for the ul, only two styles needed here. First being ‘list-style: none’ this removes the the bullet points next the list items. The second style is for the padding, removing the default padding and adding a slight bit of padding to the right, we will use the shorthand here and set all 4 sides with one line ‘padding: 0 12px 0 0’.

For the list items themselves we only need another two styles, the font styling itself will be placed on the ‘a’ tag within the list items. Here we space out the list items with a margin bottom of .65em and align the text to the right.

On the ‘a’ tag we will set the font size, font colour and the remove the default underline an ‘a’ tag gives. You will see the sizes and colour we use below but you can pick your own to match the project you’re working on.

When it comes to nav logo depending on the size and content you may need to style this differently than us but for the logo the client uses to position it properly we use the following styles.

Now the nav is completely styled we can move on to making it functional. The first part of making it functional is to hide the nav from view, this is done with a transform style. We need to add ‘transform: translateX(-100%)’ to the ‘.nav’, this hides the nav off the page to the left.

We also need to create the class that we will add to the nav later with javascript. We add this class to the containing nav element in CSS and call this class open with the style ‘transform: translateX(0)’. When this class has been added the nav will sit where it did before we added the previous ‘transform: translateX(-100%)’.

The javascript is actually a very simple piece of code which once ‘.nav-toggle’ has been clicked toggles the class ‘open’ on the nav element. It’s the only piece of code needed and looks like this: (Make sure you have jQuery added to your project)

If you test this now you will notice two things, first being that when the nav shows it just jumps into place rather that sliding smoothly. Second, the nav toggle doesn’t indicate in anyway that it’s been clicked. We will change these two things now.

Starting with the animation side of things we will add a transition to a few elements to make sure that the nav slides in and the nav toggle bars will animate properly.

Another quick test and you will see the nav now slides in and out smoothly, you can either speed or slow down this transition by changing the .3s for whatever you’d like.

The very last part of this is to animate to nav toggle and hamburger bars on click. We need to add a few styles to the ‘.nav-toggle’ container, these being the position, background colour and box-shadow colour. We add a transform set to ‘transform: translateX(167px)’, if you changed the width of the nav you may need to adjust this. The background colour change is just to make it slightly more transparent and the box shadow is to change it to completely transparent. The styles for these changes are:

The styles for the hamburger bars are simple but effective, we start by adding a transition delay to ‘.bars’ which applies to all 3 and then move to individually styling each bar. The first bar takes a transform which moves it down 7px and rotates it 45 degrees. The second bar gets hidden by an opacity set to 0. And last but not least the third bar gives given the same styles applied as the first but swapped to negative, it’s moved up by -7px and rotated -45 degrees. All 4 style declarations are below for you to see.

If you’ve followed this tutorial through you should now have a fully functional nav bar that’ll work and look great on both mobile and desktops. We will shortly be adding a demo page where you can interact and dissect it if you curious about anything… Enjoy!


FREE Clipboard Icons

Yes, another freebie icon set, hand crafted by Tidy Design. Are you looking for a flat clipboard icon with a list, some stats, a graph or tick?

Download Icons

These FREE clipboard icons can be used on commercial or non-commercial projects, all we ask in return is not to re-sell or distribute our work via any third party websites. Like them? Please link back to this post our FREE Stuff page, help us spread the word, sharing is caring… We hope you find a home for these tidy free clipboard icons, thanks for visiting!

FREE Music Icons

Looking for FREE music icons? Cool, we have created a music icon set for you to download; it includes a microphone, iPod, speaker, sound bars…

Download Icons

You can use these free music icons on both commercial and non-commercial projects, all we ask in return is not to re-sell or distribute Tidy Design FREE Stuff via any third party websites. Please be awesome and add a link back to Tidy Design if you use these icons as part of a web or graphics project… You will find even more freebies on our FREE Stuff page – Enjoy!

FREE Profile Icons

To celebrate its Friday we have created some FREE profile picture icons. These FREE icons are ideal placeholders for staff or user profiles, enjoy!

Download Icons

Please note all Tidy Design FREE Stuff (including these super awesome profile pictures) can be used on both commercial and non-commercial projects, all we ask in return is not to re-sell or distribute our work – If you decide to use these icons as part of your web project then please remember; sharing is caring, please tweet or post a link to this page…

FREE Arrow Icons

Earlier today Mr Blayne Phillips created a FREE Arrow Icon set, these (along with a few other freebies) have been added to our FREE Stuff page…

Download Icons

Please feel free to use these FREE Arrow Icons on both commercial and non-commercial projects, all we ask in return is not to re-sell or distribute our work. If you like what you see then please link back to this website or give us a mention on twitter, this would be appreciated and spur us on to make even more freebies…

If you have any requests or ideas for our FREE Stuff page then why not post them below, we will always do our best to accommodate. Thank you for visiting, until next time – keep it tidy!

CSS Rotate

The CSS transform property has many different outcomes: skew, rotate, scale, translate etc. Today we are going to focus on the rotate effect, showing how it is used and an example of its use.

We are going to rotate an image 360 degree on hover to demonstrate its effect. A basic page has been set up with the image in the centre:


To rotate the image on hover we will need to add this code to our IMG styling in our CSS. For convenience my styling is in the head but note styling should go in an external CSS file. Below is my styling for the image above.

display: block;
height: auto;
margin: 100px auto 0;

Rotating the image is actually pretty simple and requires two extra pieces of CSS styling. The first is to add the :hover pseudo class to our img tag. Once we have this in place we can add the transform style. See below:

-ms-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);

I have included all browser prefixes: Chrome, IE, Firefox, Opera, to ensure it functions on the up to date browsers. As you can see the transform property itself takes different styles and rotate is one of them. The rotate style uses degrees to move an element, 360deg as shown above rotates the element around once.

The final property that needs to be inserted is the transition property. This allows us to see the element rotate. Without it there would be no smooth transition from one state to the next. See below:

display: block;
height: auto;
margin: 200px auto 0;
-ms-transition:all 500ms linear;
-webkit-transition:all 500ms linear;
-moz-transition:all 500ms linear;
-o-transition:all 500ms linear;
transition:all 500ms linear;

We have added to our previous code above and again included the vendor prefixes. Check it out in your browser and see how it works. Cool effects and styling can be accomplished with the transform property. No need to add hover effects and instead can have more than just vertical and horizontal lines on a page… Preview CSS Rotate

Blayne Phillips

FREE Server Icon

Earlier this year we created several different server icons for a new client. As some of these server icons did not get used, we have uploaded a couple for you to download. Yes you guest it, another tidy freebie…

Download (PNGs)

Please note these FREE server icons can be used on commercial or non-commercial projects, all we ask in return is not to re-sell or distribute our work. If you decide to use these icons as part of a project, please be cool and share a link to this page – Thank you!

You will find lots more FREE Stuff on our site, enjoy!

FREE Calendar Icon PNG

As it has been such a productive day at Tidy HQ, we have created another freebie! Some free calendar icons to use on commercial or non-commercial projects…

FREE Calendar Icon PNG

Download Icons

Here you have three tidy calendars all in PNG format, 1000 x 1000 pixels – Ideal for an app or web project. These free calendar icons could be used to represent an important date, news item, upcoming event or schedule. We hope you find a good home for them.

Please note you are not permitted to resell or distribute these FREE calendar icons via any third party sites, if you like them please link back to this page – Thank you for visiting the Tidy Blog, we hope you enjoyed your stay and find time to comment below.

Check out our FREE Stuff page…

FREE Statistic Icons

Looking for a really simple statistic icon to use as part of your web project, commercial or non-commercial? Well, check out these free PNG’s below!

FREE Statistic Icons

Download Icons

We have today created and zipped up X4 statistic icons for you, the resolution of each is 500 x 500 pixels, more than enough for any app or website. We hope these free stat icons have helped – If so, please spread the word by using the social links below.

One last thing; you are not permitted to resell or distribute these statistic icons via any third party sites. If you like them, be awesome and link to this page. Thank you!