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 trial

CSS CSS Transitions and Transforms Transition Timing Functions and Delays Timing Functions and Delays Challenge

Ricard Taujenis
Ricard Taujenis
4,383 Points

Using the shorthand, transition the flex-grow property of .nav-item over .5 seconds.

not shure whats done wrong

style.css
/* nav-item transitions ---------- */

.nav-item {
    flex-grow: 1;
  transition-property: opacity: .5;
}

.nav-item:hover {
    flex-grow: 2;
   transition-property: opacity: .5;
}

/* nav icon transitions ---------- */

.icon {
  right: -25px;
}

.nav-item:hover .icon {
    right: 12%;
}
index.html
<!DOCTYPE html>
<html>
<head>
    <title>CSS Transitions</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">

        <nav class="nav">
            <a class="nav-item" href="#">About <i class="icon material-icons">person</i></a>
            <a class="nav-item" href="#">Work <i class="icon material-icons">work</i></a>
        </nav>

    </div>
</body>
</html>

6 Answers

I just checked it, and it works fine. I see I probably mis-lead you. I had written the challenge's request's as a separate rule, and the editor accepted it:

.nav-item {
    flex-grow: 1;
}

.nav-item {
   transition-property: flex-grow;
   transition: .5s;
}

But point taken, it's more economical to write it all as one rule:

.nav-item {
   flex-grow: 1;
   transition-property: flex-grow;
   transition: .5s;
}

You need to target the property first, and then set the transition:

.nav-item {
   transition-property: flex-grow;
   transition: .5s;
}
Ricard Taujenis
Ricard Taujenis
4,383 Points

thx but it still dosnt work :/ ? have to pay more attention probably not wise learning Js simultaneously

hamad Al Ali
hamad Al Ali
3,893 Points

Doesn't the shorthand transition property automatically target the property?

instead of what you've written, you should also be able to write:

transition: flex-grow, .5s;

However, for some reason I'm getting an error, I'm not sure if thats a glitch in the code challenge or its that transition shorthand is not sufficient to target the transition-property.

Thanks!

Marvin Ndifon
Marvin Ndifon
6,704 Points

using shorthand is better

.nav-item{ transition: flex-grow, 0.5s; }

Shivdev Kang
Shivdev Kang
12,737 Points

Hi Richard, when adding your transition-duration remember to use 'seconds' or 'milliseconds' even in shorthand.

Plus you need to target the correct property of 'flew-grow', opacity isn't the valid property to target.

.nav-item {
  flex-grow: 1;
  transition: flex-grow .5s;
}

.nav-item:hover {
  flex-grow: 2;
}

/* nav icon transitions ---------- */

.icon {
  right: -25px;
}

.nav-item:hover .icon {
  right: 12%;
}

You didn't add the 's' after stating your duration in your code.

I hope this helps.

Tomasz Sporys
Tomasz Sporys
11,258 Points

I was caught on the same error scratching my head saying : what is wrong with my version? heheh :)

/* nav-item transitions ---------- */

.nav-item { flex-grow: 1; transition-property: opacity: .5; }

.nav-item:hover { flex-grow: 2; transition-property: opacity: .5; }

Hello everyone, this is how I did it:

.nav-item { flex-grow: 1; }

.nav-item:hover { flex-grow: 2; }

/* nav icon transitions ---------- */

.icon { right: -25px; }

.nav-item:hover .icon { right: 12%; }

.nav-item { transition-property: flex-grow; transition-duration: .5s; }