2016-05-20 8 views
1

何らかの理由でFirefoxが好きではない:ホバー。しかし、コードはChromeでも正常に動作します。:ホバーはChromeでは動作するがFirefoxでは動作しない

HTML:

<div class="map"> 
    <%= image_tag("worldmap.png", :usemap => "#worldmap", :class => "mapper") %> 
    <map name="worldmap"> 
    <area shape="rect" coords="505,244,546,278" class="target" data-textboxleft="Text 1"> 
    <area shape="rect" coords="481,189,503,207" class="target" data-textboxleft="Text 2"> 
    </map> 
</div> 

CSS:あなたはあなたの現在のコードとあなたが望む効果を実現して、ホバーセレクター:

.target[data-textboxleft]:hover:after { 
    content: attr(data-textboxleft); 
    background: rgba(0,0,0,0.5); 
    color: white; 
    font-family: Papyrus; 
    font-size: 16px; 
    font-style: oblique; 
    height: 50px; 
    width: 180px; 
    position: absolute; 
    text-align: center; 
    padding-top: 12px; 
    left: 0; 
    top: 0; 
} 
+1

単なる '以上それができるようにこれが見えます:hover'問題は - ホバーFFで正しく動作します。クラスセレクタ( '.target')+属性セレクタ(' '[data-textboxleft]')+擬似クラスセレクタ( ':hover')+擬似要素セレクタ(':after' )すべて同じセレクタに** ** imagemapの上に** - それは単にあまりにも多すぎる可能性があります。 –

+1

codepen.ioまたはjsfiddle.comでシンプルなデモを行うことができます –

+1

また、ASPコードではなく、実際にレンダリングされたマークアップを見る方が便利です。 –

答えて

0

は私が最終的にjQueryを使ってそれを考え出し[これらの答えを見てください。

<script> 
    $(document).ready(function(){ 
     $("area").mouseover(function(){ 
      $("#boxleft").fadeIn(0); 
      document.getElementById("boxleft").innerHTML = $(this).data('name') 
     }); 
     $("area").mouseout(function(){ 
      $("#boxleft").fadeOut(0); 
     }) 
    }); 
</script> 

<div class="map"> 
    <%= image_tag("worldmap.png", :usemap => "#worldmap", :class => "mapper") %> 
    <map name="worldmap"> 
    <area shape="rect" coords="505,244,546,278" class="target" data-name="Text 1"> 
    <area shape="rect" coords="481,189,503,207" class="target" data-name="Text 2"> 
    <span id="boxleft"></span> 
    </map> 
</div> 

CSS:

#boxleft { 
    display: none; 
    background: rgba(0,0,0,0.5); 
    color: white; 
    font-family: Papyrus; 
    font-size: 14px; 
    font-style: oblique; 
    opacity: 1; 
    height: 50px; 
    width: 180px; 
    position: absolute; 
    text-align: center; 
    padding-top: 12px; 
    left: 0; 
    top: 0; 
    border: 2px solid $gray-lighter; 
} 
0

面積要素は受け付けません。 jQuery Plugin、MapHilight、キャンバスを使用する方法はいくつかあります。

Visible Area tag?How to apply Hovering on html area tag?

+0

Errrgh ...私はそれを恐れています:/実際にはタグをハイライトするmapper.jsのJavaScriptがあります。マップの左上隅に抽出テキストボックスが表示されているだけです。 Chromeが唯一の例外であるのはなぜですか? – Evilmuffin

関連する問題