2011-08-16 16 views
2

ロールオーバー時に画像ボタンを緑色から黄色に変更したいと思います。マウスオーバーで画像ボタンを変更する方法

は、ここに私のCSSコード

a#try-it-button { 
    width:273px; 
    height:47px; 
    margin-left:25px; 
    margin-top:372px; 
    background:url(../image/try-it-green.png); 

} 
a#try-it-button:hover { 
     width:273px; 
    height:47px; 
    margin-left:25px; 
    margin-top:372px; 
    background:url(../image/try-it-orange.png); 
} 
a.alt { display: none; } 

私のhtmlコード事前に

<div id="y-moringa"> 


<a id="try-it-button" href="#"><span class="alt"></span></a> 

</div> 

おかげです。

+0

どのように動作しませんか?リンク( 'a')に目に見えるコンテンツがある場合、これはちょうどCSSを使って[既に動作しています](http://jsfiddle.net/davidThomas/hR589/)です。 –

答えて

0

テストされていないが、これに打撃与える:

a#try-it-button { 
    width:273px; 
    height:47px; 
    margin-left:25px; 
    margin-top:372px; 
    display:block; // <-- **I added this** 
    background:url(../image/try-it-green.png); 

} 
a#try-it-button:hover { 
    background:url(../image/try-it-orange.png); 
} 
2

a#try-it-buttonfloat: leftまたはdisplay: inline-blockまたはdisplay: blockを追加します。

あなたが望むレイアウトのどれがあなたが望むレイアウトに本当に依存していますか?

:hoverのすべてのプロパティを複製する必要はありません(新しいbackgroundを除く)。

"CSS Sprites"(多くの利点があります)を使用して、background-position:hoverに調整してください。

関連する問題