0

こんにちは私はページの下部に表示されているツールチップを持っています。mouspointerの直後に表示されます。現在IEで動作していますが、Chromeでは動作していません。

これが私のhtmlコードです

    <div style="width:958px; margin:auto">
      <div id="diy_content">

         <div> 
            <a class="tip_trigger" href="shttp://www.purplecoffer.com" 
              onMouseOut="MM_swapImgRestore()" 
              onMouseOver="MM_swapImage('purplecoffer','','http://beta.brownbag.ph/diy/mini-banners/purplecoffer.jpg',1)">
            <img src="http://beta.brownbag.ph/diy/mini-  banners/purplecoffer_2.jpg" name="purplecoffer" width= "150px" height = "100px"border="0">
            <span class="tip" style="width: 400px;"><img src="http://beta.brownbag.ph/diy/mini-banners/purplecoffer.jpg" style="float: left; margin-right: 20px;" alt="" />
            Purple Coffer <br/>
            Apparel and Clothing <br/>
            VISIT: www.purplecoffer.com         
            </span>
            </a>
         </div>
     </div>
   </div>

これが私のCSSです

/*--Tooltip Styles--*/
.tip {
    position:absolute;    
    z-index:1000;
    color: #fff;
    background:#1d1d1d;
    padding:10px;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;
}

.tip_trigger .tip { display:none; } 

そして、これが私の機能です

    $(document).ready(function() {
    //Tooltips
        $('.tip_trigger').each(function() {        
        var tip = $(this).find('.tip');

        $(this).hover(
            function() { tip.appendTo('body');},
            function() { tip.appendTo(this); }
        ).mousemove(function(e) {
            var mousex = e.pageX + 20; //Get X coodrinates
            var mousey = e.pageY + 20; //Get Y coordinates
            var tipWidth = tip.width(); //Find width of tooltip
            var tipHeight = tip.height(); //Find height of tooltip

            //Distance of element from the right edge of viewport
            var tipVisX = $(window).width() - (mousex + tipWidth);
            //Distance of element from the bottom of viewport
            var tipVisY = $(window).height() - (mousey + tipHeight);

            if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
                mousex = e.pageX - tipWidth - 20;
            } if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
                mousey = e.pageY - tipHeight - 20;
            } 
            tip.css({  top: mousey, left: mousex  });

        });         
        });
});
4

0 に答える 0