2014-12-13 79 views
-4
<img onmouseover="http://www.habbohut.com/_images/_content/_habbohut/facebook_sign2.png" 
    align="right" 
    alt="facebook" 
    name="facebook" 
    width="231" 
    height="231" 
    border="0" 
    id="facebook" 
    style="margin-top: -12px; margin-right: -60px;"> 

它不起作用。它作爲一個盒子出現,而不是一個破碎的圖像,而是一個不顯示圖像的盒子。我將它添加到我的網站,我可以把它放在錯誤的地方?此外,我把它放在我的論壇封裝中,我希望顯示圖像,當你將鼠標懸停在它上面時,它會變成圖像2,請幫助。更改鼠標上的圖像

+0

什麼'它'不工作? – 2014-12-13 09:05:11

+1

代碼請使我們能夠識別IT:P – 2014-12-13 09:06:17

+0

我的代碼沒有出現OMG!幫我請不要離開 – Absorption 2014-12-13 09:06:36

回答

1

如果您打算改變鼠標懸停的形象,你可以使用這個:

<img onmouseover="this.src='http://www.habbohut.com/_images/_content/_habbohut/facebook_sign.png'" 
 
    onmouseout="this.src='http://www.habbohut.com/_images/_content/_habbohut/facebook_sign2.png'" 
 
    src="http://www.habbohut.com/_images/_content/_habbohut/facebook_sign2.png" 
 
    align="right" 
 
    alt="facebook" 
 
    name="facebook" 
 
    width="231" 
 
    height="231" 
 
    border="0" 
 
    id="facebook" 
 
    style="margin-top: -12px; margin-right: -60px;">

this.src='something' 

將圖片src設置爲something

但是,使用CSS並將其作爲背景圖像會更漂亮,那麼它將在沒有javascript的情況下工作。

+0

評論是不適合擴展討論;這個對話已經[轉移到聊天](http://chat.stackoverflow.com/rooms/66816/discussion-on-answer-by-mightypork-change-image-on-mouse-over)。 – Taryn 2014-12-13 16:05:44

0

請使用一些CSS,內聯樣式代碼變得非常混亂。

如果你想這樣做的很好的方式做這樣的事情:

#facebook { 
 
    background: url("http://www.habbohut.com/_images/_content/_habbohut/facebook_sign2.png") no-repeat; 
 
    width: 231px; 
 
    height: 231px; 
 
    margin-top: -12px; 
 
    margin-right: -60px; 
 
} 
 
#facebook:hover { 
 
    background: url("http://www.habbohut.com/_images/_content/_habbohut/facebook_sign.png") no-repeat; 
 
}
<div id="facebook"></div>

+0

我會試試這個謝謝 – Absorption 2014-12-14 02:25:52

0

這可能不是正確的,但是從看你的代碼的IMG腳本不結束。

您需要有/>

+0

** HTML4 **沒有自閉元素,而'/>'完全意味着其他東西。在** HTML5 **中,[開始標籤](http://www.w3.org/html/wg/drafts/html/master/syntax.html#start-tags)中的'/'字符對[void elements](http://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements)(如'img')。 – 2014-12-13 23:35:28

+0

所以我應該添加/>它? – Absorption 2014-12-14 02:25:01

+0

這就是我會嘗試,但我不知道是否會,如果它確實請告訴我。 – 2014-12-18 00:17:39