Skip to content

Instantly share code, notes, and snippets.

@nhoizey
Created June 5, 2012 11:51
Show Gist options
  • Save nhoizey/2874547 to your computer and use it in GitHub Desktop.
Save nhoizey/2874547 to your computer and use it in GitHub Desktop.
SVG: <use> of an <image>
<!-- Live demo : http://bl.ocks.org/2874547 -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>&lt;use&gt; of an &lt;image&gt;</title>
</head>
<body>
<svg version="1.1" baseProfile="basic" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="board" viewBox="0 0 320 460" width="100%" height="100%" preserveAspectRatio="xMidYMid meet">
<defs>
<image id="piece1" xlink:href="m1.svg" width="32" height="32" />
<image id="piece2" xlink:href="m2.svg" width="32" height="32" />
<image id="piece3" xlink:href="m3.svg" width="32" height="32" />
</defs>
<g id="main">
<use xlink:href="#piece1" x="0" y="0" />
<use xlink:href="#piece2" x="32" y="0" />
<use xlink:href="#piece3" x="64" y="0" />
<use xlink:href="#piece2" x="0" y="32" />
<use xlink:href="#piece3" x="32" y="32" />
<use xlink:href="#piece1" x="64" y="32" />
<use xlink:href="#piece3" x="0" y="64" />
<use xlink:href="#piece1" x="32" y="64" />
<use xlink:href="#piece2" x="64" y="64" />
</g>
</svg>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment