svg glyph替代

To create a clickable map on a website – for example, to create a world map for an company with several international distribution centers –  imagemaps have been the traditional solution: bitmaps with linked “hotspots” written in HTML. While this works, imagemaps have several significant limitations in modern web design:

要创建一个网站上的点击地图-例如,创建一个公司的世界地图与多家国际配送中心- 图像映射一直是传统的解决方案:写在连接的“热点”位图HTML 。 在此可行的同时,图像映射在现代Web设计中具有几个重大限制:

  • Imagemaps take significant time to develop, due to the fact that the hotspots must be plotted by hand.
    由于必须手动绘制热点,因此图像地图需要花费大量时间来开发。
  • While you can scale the bitmaps that makes up the imagemap, the plotted points in HTML do not scale, “drifting” the hotspots out of registration with their associated visual area.

    虽然您可以缩放组成图像图的位图,但HTML中的绘制点不会缩放, 不会将热点“漂移”到其关联的可视区域中。

  • Bitmaps tend to drop in quality or have an uncomfortably large file size when they are scaled, making them inappropriate for responsive websites.

    位图在缩放时往往会降低质量或具有不舒适的大文件大小,因此不适合响应式网站。

As an alternative, I would suggest using SVG, which avoids these limitations entirely:

作为替代方案,我建议使用SVG ,它可以完全避免这些限制:

  • Accurate SVG maps of every nation and the world are already available for free (Wikipedia is a great resource, as is Régis Freyd’s MapsIcon project) with plotted outlines that can easily be turned into hyperlinked hotspots.

    每个国家和世界的准确SVG地图都已经免费提供( 维基百科是一个很好的资源, RégisFreyd的MapsIcon项目也是如此 )具有绘制的轮廓,可以轻松地将其转换为超链接的热点。

  • As vector outlines, SVG files tend to be very small in file size.
    作为矢量轮廓,SVG文件的文件大小往往非常小。
  • As vectors, SVG can be infinitely scaled without loss in quality or lack of registration.
    作为向量,SVG可以无限缩放,而不会损失质量或缺少配准。

As an example, I’ll use a map of lower western Canada, edited in Adobe Illustrator from Wikipedia’s SVG file of a Canadian map, then cleaned up in a text editor. The start of the file looks like this:

例如,我将使用加拿大下西部的地图,该地图是在Adobe Illustrator中从Wikipedia的加拿大地图的SVG文件中编辑的,然后在文本编辑器中进行了清理。 文件的开始看起来像这样:

<svg version="1.1" xmlns="//www.w3.org/2000/svg" viewBox="0 0 525 365"><path id="ab" fill="#D3D3D3" d="M351.371, 342.397c-55.342, 1.268-49.207, 1.742-54…" />
</svg>

Each path outlines the shape of a Canadian province.  They can be linked using standard <a> tags, with the href attribute and root svg element supplemented with the xlink namespace that SVG requires.

每条路径都概述了加拿大省的形状。 可以使用标准<a>标记链接它们,并在href属性和root svg元素后添加SVG所需的xlink命名空间 。

<svg version="1.1" xmlns="//www.w3.org/2000/svg" viewBox="0 0 525 365" xmlns:xlink="//www.w3.org/1999/xlink"><a xlink:href="//travelalberta.com/"><path id="ab" fill="#D3D3D3" d="M351.371,342.397c-55 …" /></a>
…
</svg>

If you try the SVG file in your browser, you’ll see that the link only becomes active when you hover over each vector shape, indicated by a cursor change. We want to provide a greater visual impact, and make the code more efficient at the same time. Removing the fill from each path, we recreate the appearance using an embedded style. As I’ve shown previously, you can address most any SVG element in a CSS declaration, just as you can HTML:

如果在浏览器中尝试SVG文件,则会看到只有将鼠标悬停在每个矢量形状上(由光标更改指示)时,该链接才会变为活动状态。 我们希望提供更大的视觉效果,并同时使代码更高效。 从每个路径中删除fill ,我们使用嵌入式样式重新创建外观。 正如我前所示,你可以在一个CSS声明应对几乎任何SVG元素,就像你可以HTML :

path {transition: .6s fill;fill: #D3D3D3;
}
path:hover {fill: #22aa22;
}

(Vendor prefixes removed in order to save space).

(为了节省空间,删除了供应商前缀 )。

Finally, make the SVG fully responsive using this technique and embed the resulting code directly in the HTML page to take full advantage of the interaction you have built.

最后, 使用此技术使SVG充分响应, 并将结果代码直接嵌入HTML页面中 ,以充分利用您已建立的交互作用。

There’s a lot more that we can do with this technique, as shown in this reading list. I would suggest this approach as an excellent replacement for many imagemap applications.

如本阅读清单所示,我们可以使用此技术做更多的事情。 我建议这种方法可以很好地替代许多图像地图应用程序。

翻译自: https://thenewcode.com/696/Using-SVG-as-an-Alternative-To-Imagemaps

svg glyph替代

svg glyph替代_使用SVG替代Imagemaps相关推荐

  1. svg 可视化操作_使用SVG和D3可视化浏览指标

    svg 可视化操作 本文是两篇系列文章中的第一篇,该系列文章演示了可视化技术,这些技术可以帮助您从数据中提取业务价值信息. 您将看到如何使用可伸缩矢量图形(SVG)和开放源代码的D3 JavaScri ...

  2. 50兆 svg 文件超过_用svg+css3实现支付宝App波浪功能

    在使用支付宝的时候,我发现了一个很有意思的功能--波浪效果,于是我钻研了一下午,觉得这玩意还真是挺有意思,大致是svg+css3来实现 于是我就简单仿写了一个波浪特效 照例,直接上功能,不多解释 知乎 ...

  3. css svg视频自适应_使用SVG和CSS步骤进行自适应的动画步行周期

    css svg视频自适应 In the previous article I talked about steps() in CSS animation, and provided a simple ...

  4. 基于vue的svg画线_基于SVG的Vue图组件库

    基于vue的svg画线 图表 (diagram-vue) A vue component library of diagrams. Vue组件图库. View Demo 查看演示 Download S ...

  5. svg 点击 事件_使用 SVG 实现圆环日期选择器

    前言 这篇文章是多年前在 SegmentFault 上的一个回答,原问题是问如何使用 Canvas 实现一个下图类似的圆环选择器,点击后会出现对应的日期.虽然已经有 Canvas 的答案了,不过当时正 ...

  6. svg动画制作_制作第一个SVG动画

    svg动画制作 Story of a designer trying to code animations instead of asking a dev to figure it out. 一位设计 ...

  7. svg动画制作_制作动画SVG横幅

    svg动画制作 I've been reading David Walsh's blog for years. The tips and tutorials he shares have helped ...

  8. canvas 元素绑定事件_绘制SVG内容到Canvas的HTML5应用

    SVG与Canvas是HTML5上绘制图形应用的两种完全不同模式的技术,两种绘制图形方式各有优缺点,但两者并非水火不容,尤其是SVG内容可直接绘制在Canvas上的功能,使得两者可以完美的融合在一起, ...

  9. img 加载 svg占位符_如何使用SVG作为占位符以及其他图像加载技术

    img 加载 svg占位符 by José M. Pérez 由JoséM.Pérez 如何使用SVG作为占位符以及其他图像加载技术 (How to use SVG as a Placeholder, ...

最新文章

  1. jsecharts如何改变占比_echarts.js多图表数据展示使用小结_蓝戒的博客
  2. WEB数据挖掘(八)——Aperture数据抽取(4):Aperture整体结构
  3. java switch 应用
  4. 像加载DLL一样加载EXE
  5. ps批量操作图片尺寸(一键执行) - 教程篇
  6. 小白视角来看传说中的卷积神经网络
  7. mysql的extra,MySQL SQL优化-重点是 extra
  8. python读取读excel,日期变成了数字,解决方法记录
  9. So easy!10 行代码写个“让你惊叹”的文章生成器 | 原力计划
  10. git HEAD detached from origin 问题的解决
  11. SpringBoot 整合 liquibase
  12. php curl get post请求
  13. 一款Spring Boot前后端分离的进销存综合管理系统源码
  14. 【Python】监控GPU温度
  15. 架构师提升技术影响力的三个阶段(一)
  16. DirectX12(D3D12)基础教程(十七)——让小姐姐翩翩起舞(3D骨骼动画渲染【1】)
  17. WPF 3D模型介绍及使用
  18. 连接请求被计算机拒绝访问,Windows 10共享打印机解决方案被拒绝访问
  19. 文件管理系统 : 增加文件的空间 增加swap文件和swap空间 详解
  20. simulator相关

热门文章

  1. c语言declared void,关于c ++:变量或字段声明为void
  2. 三菱fx5u CCD控制plc程序(含触摸屏程序)
  3. c.k是怎样的一个人
  4. setInterval设置停止和循环 (实用)
  5. file format not recognized
  6. 【python爬虫】一个简单的爬取百家号文章的小爬虫
  7. 11.pgsql批量插入测试数据测试
  8. 电子信息制造业解决方案,电子工业采购监管、管理、降本可控化
  9. 解决浏览器主页被劫持为hao123
  10. docker 在线运行c语言程序,在docker中运行mpi应用程序