最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

用CSS中的map標(biāo)簽制作單圖多區(qū)域點(diǎn)擊的示例

segmentfault   發(fā)布時(shí)間:2015-07-20 18:04:58   作者:dopppler   我要評論
這篇文章主要介紹了CSS中的map標(biāo)簽制作單圖多區(qū)域點(diǎn)擊的示例,可在同一張圖片上實(shí)現(xiàn)多個(gè)點(diǎn)擊事件的熱點(diǎn),需要的朋友可以參考下

map標(biāo)簽

定義一個(gè)客戶端圖像映射。圖像映射(image-map)指帶有可點(diǎn)擊區(qū)域的一幅圖像。

    area元素永遠(yuǎn)嵌套在map元素內(nèi)部。area元素可定義圖像映射中的區(qū)域。
    img標(biāo)簽中的usemap屬性可引用的map標(biāo)簽中的id或name屬性(取決于瀏覽器),所以我們應(yīng)同時(shí)向map標(biāo)簽添加id和name屬性。

示例

例如我們想在下面一張圖實(shí)現(xiàn)九個(gè)熱點(diǎn)區(qū)域,不切圖,就使用map標(biāo)簽。
2015720180749341.jpg (440×494)

首先用 ps 得到幾個(gè)坐標(biāo):
2015720180825615.jpg (600×415)

然后代碼實(shí)現(xiàn):

CSS Code復(fù)制內(nèi)容到剪貼板
  1. <!DOCTYPE html>   
  2. <html lang="en">   
  3. <head>   
  4.     <meta charset="UTF-8">   
  5.     <title>Document</title>   
  6. </head>   
  7. <body>   
  8.     <img src="cat.jpg" alt="" usemap="#catmap" >   
  9.     <map name="catmap">   
  10.         <area shape="rect" coords="0,0,148,139" href ="http://www.baidu.com" target ="_blank" alt="">   
  11.         <area shape="rect" coords="148,139,295,0" href ="http://www.sina.com" target ="_blank" alt="">   
  12.         <area shape="rect" coords="295,0,439,140" href ="http://www.qq.com" target ="_blank" alt="">   
  13.         <area shape="rect" coords="148,139,0,340" href ="http://www.163.com" target ="_blank" alt="">   
  14.         <area shape="rect" coords="148,139,296,340" href ="http://www.soso.com" target ="_blank" alt="">   
  15.         <area shape="rect" coords="296,340,439,140" href ="http://sf.gg" target ="_blank" alt="">   
  16.         <area shape="rect" coords="0,340,148,493" href="http://www.zhihu.com" target ="_blank" alt="">   
  17.         <area shape="rect" coords="148,493,296,340" href="http://z.cn" target ="_blank" alt="">   
  18.         <area shape="rect" coords="296,340,436,490" href="http://jd.com" target ="_blank" alt="">   
  19.     </map>   
  20. </body>   
  21. </html>  

就是這樣。
關(guān)于area

    area 可以是圓形(circ),多邊形(poly),矩形(rect),不同形狀要選取不同的坐標(biāo)(coords).

    圓形:shape="circle",coords="x,y,z"
    x,y為圓心坐標(biāo)(x,y),z為圓的半徑

    多邊形:shape="polygon",coords="x1,y1,x2,y2,x3,y3,..."
    每一對x,y坐標(biāo)都定義了多邊形的一個(gè)頂點(diǎn)(0,0) 是圖像左上角的坐標(biāo))。定義三角形至少需要三組坐標(biāo);高緯多邊形則需要更多數(shù)量的頂點(diǎn)。

    矩形:shape="rectangle",coords="x1,y1,x2,y2"
    第一個(gè)坐標(biāo)是矩形的一個(gè)角的頂點(diǎn)坐標(biāo),另一對坐標(biāo)是對角的頂點(diǎn)坐標(biāo),"0,0" 是圖像左上角的坐標(biāo)。請注意,定義矩形實(shí)際上是定義帶有四個(gè)頂點(diǎn)的多邊形的一種簡化方法。(就是說,知道對角的兩個(gè)點(diǎn)的坐標(biāo)就行了。)

相關(guān)文章

最新評論

霸州市| 西宁市| 防城港市| 莱芜市| 武川县| 长寿区| 佛坪县| 灵台县| 德江县| 富蕴县| 夏邑县| 永新县| 方城县| 呼玛县| 乌兰县| 沽源县| 咸丰县| 宜州市| 建宁县| 仙游县| 临湘市| 财经| 山东省| 韶山市| 鄄城县| 罗城| 新宁县| 蚌埠市| 大姚县| 高雄市| 永福县| 云阳县| 曲松县| 凭祥市| 威远县| 湖州市| 杭锦后旗| 灵台县| 黑水县| 禄劝| 赣州市|