重要なお知らせ

「教えて! goo」は2025年9月17日(水)をもちまして、サービスを終了いたします。詳細はこちら>

電子書籍の厳選無料作品が豊富!

下記の例のように、「map.gif」という画像の各箇所ごとにそれぞれのリンクを貼るのは下記の方法で出来ると思うのですが、 「coords="22,11,122,62"」にマウスが乗ったときに指定した箇所に文章を表示するにはどうしたらよいのでしょうか?
※それぞれの箇所によって、それぞれ違った文章を表示したいです。
※「map.gif」という画像が表示されている上段(下段でもOK)に枠を作って、その中に説明文が表示される仕組み。


<img src="map.gif" alt="サンプル" usemap="#sample">

<map name="sample">
<area shape="rect" coords="22,11,122,62" href="map1.html" alt="リンク1">
<area shape="circle" coords="184,86,30" href="map2.html" alt="リンク2">
<area shape="poly" coords="87,78,30,110,81,139,69,113" href="map3.html" alt="リンク3">
<area shape="default" href="map4.html" alt="リンク4">
</map>

宜しくお願いします。

A 回答 (3件)

こっちのほうが簡単、良くみりゃ<ul><li>は意味ない。



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
_<meta http-equiv="content-type" content="text/html; charset=Shift_JIS">
_<title>サンプル</title>
_<meta name="author" content="ORUKA1951">
_<meta http-equiv="Content-Style-Type" content="text/css">
_<link rev="made" href="mailto:oruka1951@hoge.com" title="send a mail" >
_<link rel="START" href="../index.html">
_<style type="text/css">
<!--
div.nav{
width:210px;height:173px;margin:10px auto;
background-image:url(./images/camera.jpg);
position:relative;
}
div.nav dl,
div.nav dl dt,
div.nav dl dd{
_list-style:none;display:block;margin:0;padding:0;
}
div.nav h3{
_margin:0;
_position:absolute;
_height:20px;width:100%;
_background-color:white;
_bottom:0;
}
div.nav dl dt a{
_display:block;
_position:absolute;
_text-indent:-200px;overflow:hidden;
}
div.nav dl dd{
_display:none;position:absolute;bottom:0;height:20px;
_background-color:white;
}
div.nav dl dt:hover a{
background-image:url(./images/camera.jpg);
overflow:visible;
}
div.nav dl dt:hover+dd{display:block;}

div.nav dt a[href="map1.html"]{
left:86px;top:94px;
background-position:-87px -249px;
width:41px;height:41px;
}
div.nav dt a[href="map2.html"]{
left:60px;top:34px;
background-position:-62px -190px;
width:20px;height:27px;
}
div.nav dt a[href="map3.html"]{
top:19px;left:90px;
background-position:-92px -174px ;
width:29px;height:27px;
}

div.nav dt a[href="map1.html"]:hover{
width:200px;
text-indent:41px;
}
div.nav dt a[href="map2.html"]:hover{
left:0px;top:34px;
background-position:0 -190px;
width:85px;
text-indent:-50px;
}
div.nav dt a[href="map3.html"]:hover{
width:200px;
text-indent:29px;
}

-->
_</style>
</head>
<body>
_<div class="header">
__<h1>タイトル</h1>
__<p>このページでは・・・・</p>
_</div>
_<div class="section">
__<h2>見出し</h2>
__<div class="nav">
___<h3>カメラの説明</h3>
___<dl>
____<dt><a href="map1.html" alt="リンク1">レンズ</a></dt>
____<dd>被写体からの光を集めてフィルムに像を作る。</dd>
____<dt><a href="map2.html" alt="リンク2">シャッターボタン</a></dt>
____<dd>シャッターを開けて撮影する。</dd>
____<dt><a href="map3.html" alt="リンク3">ファインダー</a></dt>
____<dd>撮影する目標を決める。</dd>
___</dl>
__</div>
_</div>
_<div class="footer">
__<h2>文書情報</h2>
__<dl class="documentHistry">
___<dt id="FIRST-PUBLISHED">First Published</dt>
___<dd>2012-08-10</dd>
___<dt id="LAST-MODIFIED">Last Modified</dt>
___<dd>2012-08-10 12:00:00 (JST)</dd>
__</dl>
__<address>&copy; ORUKA1951 2012 - 2016 All Rights Reserved mailto:*****</address>
_</div>
</body>
</html>
    • good
    • 0

No.1です。


>一枚の画像に、四角形の選択領域が複数ある仕様でよいので、教えていただけないでしょうか?
 HTMLがわからないので示しようがないのですが、HTMLさえちゃんと書かれていたらスタイルシートで好きに細工できます。
 時間が取れたので、良い練習になるので遊んでみました。次のような説明文であるHTMLがあるとします。
★単純な定義リストを使ったナビゲーションです。
 ポイント*HTMLには文書構造だけを率直に書く。検索エンジンもスクリーンリーダーも理解できるし、自分がとにかく楽です。
★イメージマップでは出来ない画像の変更も使ってあります。
 ⇒ナビゲーションリストを様々にデザインしてみよう。( http://www.ichiya.com/WebService/Howto/sample/HT … )
 も参考になるでしょう。
★タブは_に置換してあるので戻す。
<div class="nav">
_<h3>カメラの説明</h3>
_<ul>
__<li>
___<dl>
____<dt><a href="map1.html" alt="リンク1">レンズ</a></dt>
____<dd>被写体からの光を集めてフィルムに像を作る。</dd>
___</dl>
__</li>
__<li>
___<dl>
____<dt><a href="map2.html" alt="リンク2">シャッターボタン</a></dt>
____<dd>シャッターを開けて撮影する。</dd>
___</dl>
__</li>
__<li>
___<dl>
____<dt><a href="map3.html" alt="リンク3">ファインダー</a></dt>
____<dd>撮影する目標を決める。</dd>
___</dl>
__</li>
_</ul>
</div>
このナビゲーションをカメラの写真の上に配置して、デザインしたいとします。説明は写真の下に表示させることを考えます。
添付の画像をHTMLと同じディレクトリにimages/というフォルダーにcamera.jpgとして保存します。420×314になるはず。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
_<meta http-equiv="content-type" content="text/html; charset=Shift_JIS">
_<title>サンプル</title>
_<meta name="author" content="ORUKA1951">
_<meta http-equiv="Content-Style-Type" content="text/css">
_<link rev="made" href="mailto:oruka1951@hoge.com" title="send a mail" >
_<link rel="START" href="../index.html">
_<style type="text/css">
<!--
div.nav{
width:210px;height:173px;margin:10px auto;
background-image:url(./images/camera.jpg);
position:relative;
}
div.nav ul,div.nav ul li,
div.nav ul li dl,
div.nav ul li dl dt,
div.nav ul li dl dd{
_list-style:none;display:block;margin:0;padding:0;
}
div.nav h3{
_margin:0;
_position:absolute;
_height:20px;width:100%;
_background-color:white;
_bottom:0;
}
div.nav ul li dt a{
_display:block;
_position:absolute;
_text-indent:-200px;overflow:hidden;
}
div.nav ul li dl dd{
_display:none;position:absolute;bottom:0;height:20px;
_background-color:white;
}
div.nav ul li dt:hover a{
background-image:url(./images/camera.jpg);
overflow:visible;
}
div.nav li dl dt:hover+dd{display:block;}

div.nav ul li dt a[href="map1.html"]{
left:86px;top:94px;
background-position:-87px -249px;
width:41px;height:41px;
}
div.nav ul li dt a[href="map2.html"]{
left:60px;top:34px;
background-position:-62px -190px;
width:20px;height:27px;
}
div.nav ul li dt a[href="map3.html"]{
top:19px;left:90px;
background-position:-92px -174px ;
width:29px;height:27px;
}

div.nav ul li dt a[href="map1.html"]:hover{
width:200px;
text-indent:41px;
}
div.nav ul li dt a[href="map2.html"]:hover{
left:0px;top:34px;
background-position:0 -190px;
width:85px;
text-indent:-50px;
}
div.nav ul li dt a[href="map3.html"]:hover{
width:200px;
text-indent:29px;
}

-->
_</style>
</head>
<body>
_<div class="header">
__<h1>タイトル</h1>
__<p>このページでは・・・・</p>
_</div>
_<div class="section">
__<h2>見出し</h2>
__<div class="nav">
___<h3>カメラの説明</h3>
___<ul>
____<li>
_____<dl>
______<dt><a href="map1.html" alt="リンク1">レンズ</a></dt>
______<dd>被写体からの光を集めてフィルムに像を作る。</dd>
_____</dl>
____</li>
____<li>
_____<dl>
______<dt><a href="map2.html" alt="リンク2">シャッターボタン</a></dt>
______<dd>シャッターを開けて撮影する。</dd>
_____</dl>
____</li>
____<li>
_____<dl>
______<dt><a href="map3.html" alt="リンク3">ファインダー</a></dt>
______<dd>撮影する目標を決める。</dd>
_____</dl>
____</li>
___</ul>
__</div>
_</div>
_<div class="footer">
__<h2>文書情報</h2>
__<dl class="documentHistry">
___<dt id="FIRST-PUBLISHED">First Published</dt>
___<dd>2012-08-10</dd>
___<dt id="LAST-MODIFIED">Last Modified</dt>
___<dd>2012-08-10 12:00:00 (JST)</dd>
__</dl>
__<address>&copy; ORUKA1951 2012 - 2016 All Rights Reserved mailto:*****</address>
_</div>
</body>
</html>
「イメージマップで文章を表示したい。」の回答画像2
    • good
    • 0

javascriptを使えば出来なくはないでしょうが・・・・


イメージマップの処理は細かい部分でブラウザ間に差が大きく、うまくは出来ないです。
ちなみに、areaを使う限りは不可能なことは分かりますよね。area要素は、(img同様)内容を持たない要素ですから、内容の追加も出来ません。
<p><img src="./images/map1.jpg" width="420" height="314" usemap="#sample"></p>
<map name="sample">
  <ul>
    <li><a shape="rect" coords="40,20,180,120" href="map1.html" alt="リンク1">あいうえお</a></li>
    <li><a shape="circle" coords="300,150,80" href="map2.html" alt="リンク2">かきくけこ</a></li>
    <li><a shape="poly" coords="125,140,200,195,172,284,78,284,49,195" href="map3.html" alt="リンク3">さしすせそ</a></li>
  </ul>
</map>
 普通にareaを使わなかったら、Operaでは何とか可能です。IEは一部、firefoxは無理

 もし四角形の領域でよいのでしたら、単純にCSSだけで実装できます。そのほうがよいかと思います。

この回答への補足

ご丁寧な回答を頂き有難う御座います。
ブラウザにより難しいところがあるのですね。

一枚の画像に、四角形の選択領域が複数ある仕様でよいので、教えていただけないでしょうか?

宜しくお願いします。

補足日時:2013/10/28 09:19
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!