Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialgyatmnucla
7,618 PointsHow to code this animation
Hi all :) I am currently working on a project and i would like to know how to replicate an animation i saw online. On this site : http://themenectar.com/demo/salient-corporate/ If you look at the top menu, when you hover over the different menu li, an underline forms. Could you tell me how to code this ? Thanks in advance
3 Answers
Fynn Lehnert
15,244 Pointswith the pseudo selector :after you can add extra stuff to an elemten and style it with css.
thats how they did it
a:after {
-webkit-transition: width .3s ease-out, left .3s ease-out, border-color .3s ease-out;
transition: width .3s ease-out, left .3s ease-out, border-color .3s ease-out;
position: absolute;
display: block;
bottom: -6px;
left: 50%;
width: 0;
border-top: 2px solid #000;
content: '';
padding-bottom: inherit;
}
this is the trigger that occurs on :hover
a:hover:after {
width: 100%;
left: 0;
}
the important part here is the content:''; its "creating" the :after. without it, youd see nothing.
happy coding!
Fynn Lehnert
15,244 Pointsput your code up to codeshare.io. tweet me the link @ mefynn ill be able to help you there
gyatmnucla
7,618 PointsI found my way :D
gyatmnucla
7,618 Pointsgyatmnucla
7,618 PointsI tried this, it didn't work.. What am I doing wrong ? Thanks btw :)