Reverse animation when taking mouse

Asked

Viewed 68 times

1

Would someone like to tell me how I do the animation "the other way around" when I take the mouse out? Try it on the link below and I think you will understand. When I put the mouse, the description of the image "goes down", I wanted when I removed the mouse it "goes up"

https://jsfiddle.net/evy1oLys/

1 answer

2

You can use Transition to change the height of the widget in the Hover sort of like this:

.our-works {
    z-index: 1;
}

.item-works {
    z-index: 99999;
    display: block;
    float: left;
    width: 24%;
    height: 8em;
    overflow: hidden;
    position: relative;
}

.item-works:hover .sub-works {
    display: inherit;
    overflow: hidden;
}

.item-works:hover .sub-works {
   
   max-height: 150px;
   transition: max-height 0.7s ease;
}

.sub-works {
  transition: max-height 0.7s ease;

    max-height: 0;
    position: absolute;
    background-color: #00aeff;
    top: 0;
    color: #fff;
    z-index: 1;
}

.link-foto {
    position: absolute;
    bottom: 0;
    left: 0;
    padding: .8em;
    text-decoration: none;
    color: #fff;
    background-color: #008bcc;
    font-weight: bolder;
}

.desc-works {
    margin-top: 1em;
    text-align: center;
}

.desc-works p {
    width: 70%;
    margin: 0 auto;
}

.img-works {
    max-width: 100%;   
}
<section class="works">
        <div class="container">
           <div class="our-works">
            <h2 class="title-section">Our Works</h2>
            <ul class="list-works">
                <li class="item-works"><img src="image/work1.png" alt="Work" class="img-works">
                    <div class="sub-works">
                        <div class="desc-works">
                        <h2 class="subtitle">Work</h2>
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                        <a href="#" class="link-foto">+</a>
                        </div>
                    </div>
                </li>
                <li class="item-works">
                   <img src="image/work1.png" alt="Work" class="img-works">
                    <div class="sub-works">
                      <div class="desc-works">
                       <h2 class="subtitle">Work</h2>
                       <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p> 
                       <a href="#" class="link-foto">+</a>
                       </div>
                    </div>
                </li>
                <li class="item-works"><img src="image/work1.png" alt="Work" class="img-works">
                    <div class="sub-works">
                       <div class="desc-works">
                        <h2 class="subtitle">Work</h2>
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                        <a href="#" class="link-foto">+</a>
                        </div>
                    </div>
                </li>
                <li class="item-works"><img src="image/work1.png" alt="Work" class="img-works">
                    <div class="sub-works">
                       <div class="desc-works">
                        <h2 class="subtitle">Work</h2>
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. </p>
                        <a href="#" class="link-foto">+</a>
                        </div>
                    </div>
                </li>
                <li class="item-works"><img src="image/work1.png" alt="Work" class="img-works">
                    <div class="sub-works">
                       <div class="desc-works">
                        <h2 class="subtitle">Work</h2>
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                        <a href="#" class="link-foto">+</a>
                        </div>
                    </div>
                </li>
                <li class="item-works"><img src="image/work1.png" alt="Work" class="img-works">
                    <div class="sub-works">
                       <div class="desc-works">
                        <h2 class="subtitle">Work</h2>
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                        <a href="#" class="link-foto">+</a>
                        </div>
                    </div>
                </li>
                <li class="item-works"><img src="image/work1.png" alt="Work" class="img-works">
                    <div class="sub-works">
                       <div class="desc-works">
                        <h2 class="subtitle">Work</h2>
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                        <a href="#" class="link-foto">+</a>
                        </div>
                    </div>
                </li>
                <li class="item-works"><img src="image/work1.png" alt="Work" class="img-works">
                    <div class="sub-works">
                       <div class="desc-works">
                        <h2 class="subtitle">Work</h2>
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                        <a href="#" class="link-foto">+</a>
                        </div>
                    </div>
                </li>
            </ul>
            </div>
        </div>
    </section>

  • But then it runs out of that "hit and go" effect, which was the purpose of keyframe use.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.