1. the ‘nth-child’ selector. Firstly, we set this to

1. Initiate documentThe first step is to initiate the HTML document. Thisconsists of the HTML document container, whichincludes sections for the head and body. The headsection contains descriptive information and links toexternal resources – in this case the CSS stylesheet. Thebody section will be populated with the visible content inthe next step.

Hamburger Effect*** STEP 22. Navigation contentThe menu is made from a navigation container thatstores a series of links. The first link in this container willbe the hamburger icon; a link that will reference thenavigation container. The hamburger icon has three spanelements, which will be styled to show as the hamburgerbars in a later step.

3. Start the stylesheetThe HTML markup is now complete, so create a newfile called ‘styles.css’ to start defining the CSS formatting.The first entry into this file will be to define the documentand content body to display with a dark backgroundwithout border spacing. We also set the font that allelements will inherit.html,body{display: block;width: 100%;height: 100%;margin: 0;padding: 0;font-family: Helvetica, sans-serif;background: rgb(21, 34, 47); }4. Navigation containerThe navigation container will be set to display at 25% ofthe document width without any margin. This isimportant if we don’t want the navigation to display overthe full page, hence defining the width controls how widethe menu is to be displayed at. A block display is alsoused to guarantee that width sizing will work regardlessof how a browser treats navigation containers by default.nav{display: block;width: 25%;margin: 0; }5. Default navigation linksBorder and width settings are applied to the links withinthe navigation container so that they appear prominentlyat the same size defined for the navigation width.Navigation links are not visible by default, but becomevisible when their parent container is targeted; hence thereason why the HTML link of the hamburger iconreferences its parent navigation container.nav a{display: none;width: 100%;padding: 10%;font-size: 1.5em;border: 3px solid #fff;background: #333;color: #fff; }nav:target a{display: block; }6. Hamburger styleThe hamburger icon will always be the first elementinside the navigation container, hence we reference itusing the ‘nth-child’ selector. Firstly, we set this to displayas a block of five character width. Secondly, the innerelements are styled as white bars in relation to thepreviously set size. Each bar has a specific margin andheight set to appear visible and separate from each other.nav > *:nth-child(1){display: block;width: 5em; }nav > *:nth-child(1) span{position: relative;display: block;width: 100%;height: .5em;margin-top: .25em;background: #fff; }7.Animation: preparationThe animation e?ect will be made from the ‘before’element that CSS can apply to web page elements. Thiswill add a bar with a red background applied to each ofthe span elements defined in the previous step. Withtheir parent span using relative positioning, the positionof these elements will be positioned in relation to theirparent. These elements are initiated with no width, readyto be animated in the next steps.nav > *:nth-child(1) span::before{content: “”;position: absolute;top: 0;left: 0;width: 0;height: 100%;background: red;transition: width 1s;}8. Animation: bar settingsFirstly, the before elements of each of the hamburgerbars need to have the ‘open’ animation applied to themwhen their parent link is being hovered. This animationwill be played ‘forwards’ to ensure that it stops on the lastframe. Secondly, the second and third bars need to havedi?erent delays applied to them for the full e?ect to work.nav > *:nth-child(1):hover span::before{animation: open 1s forwards; }nav > *:nth-child(1):hover span:nthchild(2)::before{animation-delay: .15s; }nav > *:nth-child(1):hover span:nthchild(3)::before{animation-delay: .3s;}9. Animation: definitionThe ‘open’ animation applied to the before elements is asimple two frame animation that changes the width fromzero to the full width of the parent burger bar. Thebrowser will fill in all of the animation frames requiredbetween these two states to show a smooth transitionlasting the time specified in the previous [email protected] open {0% {width: 0;}100% {width: 100%;}}  

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now
x

Hi!
I'm Homer!

Would you like to get a custom essay? How about receiving a customized one?

Check it out