2017-06-02 3 views
1

テキストボックスの隣の小さいイメージにマウスをかざすとイメージが表示されますが、2番目のイメージは小さいイメージより大きくなりますそれが何度も現れたときに左のものが跳ね返る。私は両方の画像が静的に表示され、2つ目の画像が最初の画像をバウンスする代わりに下向きに表示されるようにしたいと思います。私はthisを実証するjfiddleを作ったが、これは私のコードです:それはちょうどに行ってきましたラジオの選択の隣にマウスオーバーイメージを表示する方法バギーバウンス効果なしでうまく表示

 \t document.getElementById('imageToHover').onmouseover = function() 
 
    \t { 
 
    \t \t document.getElementById('imageToShow').style.display = 'inline'; 
 
    \t } 
 
    
 
    \t document.getElementById('imageToHover').onmouseout = function() 
 
    \t { 
 
    \t document.getElementById('imageToShow').style.display = 'none'; 
 
    \t }

 
    #imageToShow 
 
    { 
 
     display: none; 
 
    } 
 
    #imageToHover 
 
    { 
 
     height= "25" width= "25"; 
 
     float: top; 
 
    }

 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
    
 

 

 

 
<b>blah blah blah?</b> 
 
     <img id="imageToHover" src="https://images-na.ssl-images-amazon.com/images/I/212yolzmnaL._AC_UL160_SR160,160_.jpg" height= "25" width= "25" alt="hover me"/> 
 
     <img id="imageToShow" src="https://media-cdn.tripadvisor.com/media/photo-s/06/8b/50/cb/quality-inn-suites-south.jpg" height= "80" width= "120" alt="image to show"/><br> 
 

 
     <input type="radio" name="options[]" value="Yes"> Yes<br> 
 
     <input type="radio" name="options[]" value="No"> No<br><br> 
 

私はそれが魔法の右側に表示されるように取得するfloat rightを使用していたと考えることができるすべてが、最後に、最初の画像にfloat:topを使ってみましたが、何もしませんでした。おそらく、div魔法があったかもしれませんが、divを使うたびに新しい行が追加され、誰も私にこの問題を解決する方法を教えてもらえますか?

+0

あなたは '' '位置を追加することができます:小さな画像と大きな1の位置に合うようになり、その後、小さな画像は、それの位置に固定しますのでabsolute'''スタイリングと追加のスタイリングを。 – aavrug

答えて

2

これを試してください。大きな画像にちょうど追加されたposition: absolute;

window.onload = function() { 
 
    document.getElementById('imageToHover').onmouseover = function() { 
 
    document.getElementById('imageToShow').style.display = 'inline'; 
 
    } 
 

 
    document.getElementById('imageToHover').onmouseout = function() { 
 
    document.getElementById('imageToShow').style.display = 'none'; 
 
    } 
 
};
#imageToShow { 
 
    display: none; 
 
    position: absolute; 
 
} 
 

 
#imageToHover { 
 
    height: 25px; 
 
    width: 25px; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="script.js"> 
 
</script> 
 

 
<body> 
 

 

 

 
    <b>blah blah blah?</b> 
 
    <img id="imageToHover" src="https://images-na.ssl-images-amazon.com/images/I/212yolzmnaL._AC_UL160_SR160,160_.jpg" height="25" width="25" alt="hover me" /> 
 
    <img id="imageToShow" src="https://media-cdn.tripadvisor.com/media/photo-s/06/8b/50/cb/quality-inn-suites-south.jpg" height="80" width="120" alt="image to show" /><br> 
 

 
    <input type="radio" name="options[]" value="Yes"> Yes<br> 
 
    <input type="radio" name="options[]" value="No"> No<br><br> 
 
</body>

+0

ありがとうthatsまさに私が探していたもの:) – 2316354654

関連する問題