これが私がこのページでスライド効果を作った方法です:dmg-01.net:
$(document).ready(function(){
$(".trail-text").attr("style", "display:none;");
if ($("#one,#two,#three,#four,#five")) {
var pixies = $("#one,#two,#three,#four,#five");
$("#one,#two,#three,#four,#five").hover( function() {
$(this).find(".trail-text").slideDown("fast");
}, function() {
$(this).find(".trail-text").slideUp("fast");
});
};
});
思ったほど優雅ではないので、改善したいと思います。スライド効果が1つだけで、重ならないようにするといいと思います。
一方、私はこの方法で同じ効果を達成しようとしました:
$(function(){
$("#one,#two,#three,#four,#five").each(function(){
$(this).hover(function(){
$(this).animate({height: "100%", width: "100%"}, {queue:false, duration:111});
},function() {
$(this).animate({height: "44px", width: "44px"}, {queue:false, duration:333});
});
});
});
高さの「自動」を設定する方法がわからず、「非表示」要素内のコンテンツが要素の外部に表示されるため、破棄しました。
これをどのように改善できますか?
私の目的によれば、CSSプロパティを使用して要素の子孫をアニメーション化することを好みます。これは私がそれをやろうとした方法ですが、それは機能していません。なんで?
$(document).ready(function(){
$(".trail-text").attr("style", "display:none;");
if ($(".#one,#two,#three,#four,#five")) {
$("#one,#two,#three,#four,#five").hover(
function() { $(this).find(".trail-text").animate({height: "100%", width: "444px"}, {queue:false, duration:111}); },
function() { $(this).find(".trail-text").animate({height: "0", width: "444px"}, {queue:false, duration:333}); }
);
};
});