ul
の最大高さを拡大しようとしています。 MAX-heightプロパティは、クラスを切り替えることにより、(変更された場合、高さが直ちに変化し、それらが必要としてul
下の要素はアニメーションの高さを尊重する。最大高さのアニメーション、他の要素の遅れ
var expander = $('.skill-expand');
var skillsUl = $('.skills-list');
expander.on('click', function() {
skillsUl.toggleClass('unexpanded');
if (skillsUl.hasClass('unexpanded')) {
expander.html('<span class="fa fa-chevron-down">..\/..</span>');
} else {
expander.html('<span class="fa fa-chevron-up">../\..</span>');
}
return false;
});
.skills-list {
margin: 0;
padding: 0;
transition: max-height 1s ease-in-out;
max-height: 800px;
/*effectively auto*/
}
.skill-expand {
margin: auto;
text-align: center;
display: block;
}
.skills-list.unexpanded {
max-height: 60px;
overflow: hidden;
transition: max-height 1s ease-in-out;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="skills-list unexpanded">
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
<li class="skill-rating">Developers developers</li>
</ul>
<a href="#" class="skill-expand"><span class="fa fa-chevron-up">..\/..</span></a>
https://jsfiddle.net/ubgmshzo/
..\/..
エキスパンダーテキストをクリックすると、エキスパンダー要素が下に移動する間に遅れがあることがわかります。理由はありますか?
優れており、完璧に動作します。ありがとう! – Echilon