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 - Beyond the Basics Understanding CSS Transitions and Transforms Transitions Challenge

David Wood
David Wood
5,705 Points

Transition fail

Ok, I am confused why is this wrong? I get a transition and return transition of .4s...

style.css
/* Complete the challenge by writing CSS below */

.button {  
  background: #4682B4;
  transition-duration: .4s;
}

.button:hover {
    background: #356690;
  transition-property: background;
  transition-duration: .4s;
index.html
<!DOCTYPE html>
<html>
<head>
    <title>CSS Transitions</title>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <a class="button" href="#">Learn More</a>
</body>
</html>

2 Answers

Jake Lundberg
Jake Lundberg
13,965 Points

You will need to put all the transition code in .button, not in the :hover. You can also save yourself a little time and do it all in one line:

.button {
   background: #4682B4;
   transition: background .4s;
}

.button:hover {
    background: #356690;
}
David Wood
David Wood
5,705 Points

Isn't the result the same? If I put it in hover or in .button. The code worked when I viewed it in preview.