Help us understand the problem. What is going on with this article?

レスポンシブなイメージマップの作成

More than 3 years have passed since last update.

1枚の画像に複数のリンクを付けるイメージマップですが、htmlとcssだけではレスポンシブに対応できないので「jQuery RWD Image Maps」というプラグインを使用します。

jQuery RWD Image Maps
https://github.com/stowball/jQuery-rwdImageMaps

実装サンプル

<script type="text/javascript" src="jquery.rwdImageMaps.min.js"></script>
html
<img src="img.png" width="800" height="115" usemap="#ImageMap">
<map name="ImageMap">
    <area shape="rect" coords="200,0,500,110" href="#" alt="" />
</map>
css
img[usemap] {
    max-width: 100%;
    height: auto;
}
js
$(document).ready(function(e) {
    $('img[usemap]').rwdImageMaps();
})

注意点はimgタグに画像が表示上の最大幅となる時widthheightを指定することです。

areaタグの座標の作成は「HTML Imagemap Generator」が便利です。
HTML Imagemap Generatorを使用する際は表示上の最大幅の画像を使用してください。

HTML Imagemap Generator
http://labs.d-s-b.jp/ImagemapGenerator/

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした