【发布时间】:2017-06-21 15:51:43
【问题描述】:
想知道是否有人可以告诉我如何制作动画以使答案逐渐显示?我在下面添加了所有代码。非常感谢您为这项工作提供任何帮助。
<div class="q-a-set">
<div class="licensing-question" id="q_1">
<i class="fa fa-caret-square-o-down" aria-label="Answer"></i> <span>Do I need to pay?</span>
</div>
<div class="licensing-answer-closed" id="a1"><span class="licensing-answer">Yes</span></div>
</div>
.licensing-question{
font-size: 2.2em;
font-weight: 700;
font-family: 'Source Sans Pro', sans-serif;
color: #a8a8a8;
cursor: pointer;
line-height: 1.2em;
margin: 0;
padding: 0;
display: inline;
}
.licensing-answer-closed{
height: 0;
visibility: hidden;
}
.licensing-answer{
color: #222222;
font-size: 1.8em;
}
var showAnswerBtn = $(".licensing-question");
var caret = showAnswerBtn.find('.fa');
showAnswerBtn.click(function () {
//alert(caret);
event.preventDefault();
var target = this.id.split('_');
var id = "a" + target[1];
$("#" + id).toggleClass('licensing-answer-closed');
$(caret).toggleClass('fa-caret-square-o-up');
});
【问题讨论】:
-
你的html/css在哪里?您可以尝试添加
.answer-closed { transition: opacity 1s; opacity: 0; },但如果没有更多上下文,您会不清楚您要做什么 -
我已将其添加到我的问题中,上面。
标签: javascript jquery css jquery-animate