0

黒から透明のグラデーションのメニューがあります。メニューにカーソルを合わせると、完全に黒く塗りつぶされます。次が機能しないのはなぜですか?

$('#topmenu').hide().animate({
    'height': 'toggle'
    }, "slow").hover(function() {$(this).animate({ 'opacity' : 1 }).css( 'background' , 'rgb(0,0,0)', 'box-shadow' , "0px 5px 15px 0px rgba(0, 0, 0, 0.5)" );}, function() {$(this).animate({ 'opacity' : 0.6  }).css( 'background' , "url('<?php bloginfo('template_url'); ?>/images/topmenu_bg.png') repeat-x" );});

メニューのbg画像は、プロパティ「background」を使用してスタイルシートを介して設定されます。

ありがとうございました。

4

2 に答える 2

1

この単純な CSS ではないのはなぜですか?

#topmenu {
    background-image:linear-gradient(to bottom,black,transparent);
    background-color:transparent;
    transition:background-color 1s ease;
    /* vendor-specific alternatives follow */
    background-image:-webkit-linear-gradient(top,black,transparent);
    -webkit-transition:background-color 1s ease;
}
#topmenu:hover {
    background-color:black;
}

CSS の「速度」を測定する方法がわからないため、プレーンな CSS は比喩的にも文字通りにも jQuery よりも計り知れないほど高速です XD

于 2013-02-18T00:13:55.633 に答える
0

複数の CSS プロパティを設定するには、プロパティを持つオブジェクトを渡す必要があります

$('#topmenu').hide().animate({
    'height': 'toggle'
    }, "slow").hover(function() {$(this).animate({ 'opacity' : 1 }).css({'background': 'rgb(0,0,0)', 'box-shadow': "0px 5px 15px 0px rgba(0, 0, 0, 0.5)"});}, function() {$(this).animate({ 'opacity' : 0.6  }).css('background', "url('<?php bloginfo('template_url'); ?>/images/topmenu_bg.png') repeat-x");});
于 2013-02-18T12:24:39.673 に答える