过渡动画以显示隐藏的内容

时间:2016-10-27 11:09:55

标签: css3 animation css-transitions show-hide

我需要在第三张幻灯片上执行Studio Up之类的操作,当我点击按钮时显示隐藏的内容,我需要做同样的效果,但我不知道如何。有谁可以帮助我吗?我在互联网上搜索但一无所获。

这是我的HTML,我不知道如何设置CSS。

<div class="services">
    <h2>Social Media</h2>
    <div class="service-icon convers"></div>
    <p>La comunicazione si è evoluta in conversazione. Siamo nati con questo        cambiamento.</p>
    <p class="answer">Inventiamo strategie e pensiamo comportamenti buoni (che valgono sempre).<br>
    Studiamo ogni giorno nuovi strumenti e servizi</p>
    <a href="#" class="button radius button-detail">e quindi?</a> 
    <a href="#" class="button radius alert button-back">indietro</a>
</div>

非常感谢你。

1 个答案:

答案 0 :(得分:1)

当您点击.button-detail时,课程.answered将添加到.services,点击.button-back并删除相同的课程

$('.button-detail').on('click',function(){
  $(this).parent().addClass('answered');
});
$('.button-back').on('click',function(){
  $(this).parent().removeClass('answered');
});

然后css会做的伎俩:

.services.answered .button-back {
    -webkit-transform: rotateX(0deg);
    -moz-transform: rotateX(0deg);
    -o-transform: rotateX(0deg);
    -ms-transform: rotateX(0deg);
    transform: rotateX(0deg);
    z-index: 10001
}

.services.answered .button-detail {
    -webkit-transform: rotateX(180deg);
    -moz-transform: rotateX(180deg);
    -o-transform: rotateX(180deg);
    -ms-transform: rotateX(180deg);
    transform: rotateX(180deg)
}

.services.answered .answer {
    height: 12.5rem;
    padding-top: 0.625rem;
    opacity: 1
}

.services.answered p {
    height: 0;
    overflow: hidden;
    margin: 0;
    opacity: 0
}

.services.answered .service-icon {
    height: 5rem;
    margin-top: 0.625rem
}

.services {
    text-align: center;
    overflow: hidden;
    position: relative;
    padding-bottom: 55px;
    color: #fff;
    height: 360px
}



.services h2 {
    font-size: 1.3125rem;
    margin-top: 1rem
}


.services p {
    margin: 0.625rem 0 0;
    font-size: 16px;
    font-weight: 100;
    line-height: 1.1;
    letter-spacing: 0.07rem;
    height: 4.25rem;
    font-family: "bariol-thin",helvetica,arial,sans-serif
}


.services .answer {
    height: 0;
    margin-top: 0;
    margin-bottom: 0;
    overflow: hidden;
    font-size: 16px;
    padding: 0.75rem 0.5rem 0;
    line-height: 19px;
    opacity: 0
}

.services .button {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -ms-backface-visibility: hidden;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    box-shadow: none!important;
    font-family: "lato-regular",helvetica,arial,sans-serif;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.8125rem 0
}

.services .button:hover {
    background-color: #FF6F5C
}

.services .button-back {
    -webkit-transform: rotateX(-180deg);
    -moz-transform: rotateX(-180deg);
    -o-transform: rotateX(-180deg);
    -ms-transform: rotateX(-180deg);
    transform: rotateX(-180deg);
    background-color: #c2371f;
    border-color: transparent
}

.services .button-back:hover {
    background-color: #862f26
}

.services .button-detail {
    z-index: 10000
}

.services p,.services .answer, .services .button, .services .service-icon {
    -webkit-transition: all 1000ms ease-in-out;
    -moz-transition: all 600ms ease-in-out;
    -o-transition: all 600ms ease-in-out;
    transition: all 600ms ease-in-out
}