基本的に、クラスを持つリンクをクリックすると、次のスパンの高さをアニメーション化するための More... リンクを取得できません"dropdown"
。それはまったくアニメーション化されません。Less...
リンクに変更され、Less...
リンクがクリックされて段落内の余分なコンテンツが折りたたまれた場合にのみアニメーション化されます。More...
コンテンツが表示されたときにアニメーション化するリンクを取得するにはどうすればよいですか? 現在、高さを切り替えていますが、代わりに何か他のことをする必要がありますか?
で次の jQuery コードを使用する$(document).ready(function() { });
$(".listitem").on("click", ".dropdown", function(event) {
event.preventDefault();
var $this = $(this);
var type = $this.next("span").length > 0 && !$this.next("span").is(":visible") ? 'expand' : 'collapse';
var theSpan = type == 'expand' ? $this.next("span") : $this.prev("span");
if (type == 'expand') {
$this.insertAfter(theSpan);
}
else
$this.insertBefore(theSpan);
theSpan.animate({height: 'toggle'}, 250, function(){
$this.text(type == 'expand' ? ' [ Less... ]' : '[ More... ]');
});
});
タグ内に次の構造化 HTML がありますul
(すべてのli
タグは同じ構造です)。
<li>
<div class="listitem">
<span style="font-weight: bold;">Headline</span> Here is some body copy for the headline that should expand with an animation when clicking on the More... link right here. <a href="#" class="dropdown red">[ More... ]</a><span class="hidden">Here is more text to be shown and it should animate when the More... link is clicked, but it currently does not!</span>
</div>
</li>
CSS:
ul
{
list-style: none outside none;
list-style-type: none;
}
ul li
{
padding: .4em;
margin-left: -20px;
}
.listitem
{
display: table;
}
.hidden
{
display: none;
}
編集
ここで問題を確認できます: http://opportunityfinance.net/Test/conference-2013/highlights.html
テキストが展開されたときに同じ行に留まる必要があります。次の行にプッシュしないでください。white-space
これを行うCSSの方法はありますか?またはおそらくdisplay: inline
??