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

How to make it reverse? transition

HI,

How do i make this transition reverse? so as it goes and scales out, i want it to scale in when the mouse is off it .

<div class="container">
    <div class="" id="portfolio">
        <div class="row">
            <div class="col-sm-3">
                <div class="project-tab">
                    <a href="http://desidree.com/"><h4>www.desidree.com</h4></a>

                    <a href="">
                        <img class="portolio-image" src="assets/img/webpor.jpg">
                    </a>

                    <a href="">
                        <img class="portolio-image-secondary" src="assets/img/webpor.jpg">
                    </a>

                </div><!-- /project-tab -->
            </div><!-- /col-sm-3 -->
        </div><!-- /row -->
    </div><!-- /portfolio -->
</div>
.project-tab{
    overflow: hidden;
    position: relative;
}
.project-tab img{
    width:100%;
    height: 320px;
}
img.portolio-image-secondary {
    position: absolute;
    top:33px;
    z-index: -1;
    height: 91%
}

img.portfolio-image {
    position: relative;
    z-index: 2;
    top:0;
}


img.portolio-image:hover{
    -webkit-transition: all .4s ease-in-out;
       -moz-transition: all .4s ease-in-out;
         -o-transition: all .4s ease-in-out;
        -ms-transition: all .4s ease-in-out;
            transition: all .4s ease-in-out;
             transform: scale(4,4);
               opacity: 0;
}

First, your hover selector has "portfolio" spelled wrong, but....

I looked at this question about an hour ago and did some testing/research and it doesn't seem like reversing a transition is possible with just :hover.

I know you can do something similar by adding/removing an extra class name (like open) but you'd have to do that with javascript. Then in your css. you'll have img.portfolio-image and img.portfolio-image.open. Then you'll set the transitions on both and be sure to declare both opacity:1 and opacity:0 (and other transitioning properties).

I haven't tested this but since you didn't have any replies I figured I'd throw something out there.