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
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="55" height="55" viewBox="-0.968 -0.699 55 55" enable-background="new -0.968 -0.699 55 55" xml:space="preserve">
<path fill="#9B993A" d="M0,26.701C0,11.953,11.961,0,26.695,0c14.758,0,26.719,11.953,26.719,26.701
c0,14.752-11.961,26.703-26.719,26.703C11.961,53.404,0,41.453,0,26.701"/>
<path fill="#FFFFFF" d="M36.613,32.357c0-3.961-2.359-6.297-5.48-6.896v-0.072c3-1.125,4.562-3.377,4.562-6.297
c0-3.771-3.281-7.139-9.082-7.139c-3.293,0-6.031,0.92-8.473,2.531l1.965,4.172c0.926-0.807,2.641-2.064,5.254-2.064
c2.977,0,4.336,1.58,4.336,3.385c0,2.164-1.719,3.531-4.496,3.531h-2.977v4.693h2.934c2.898,0,5.379,1.031,5.379,4.283
c0,2.404-2.039,4.164-5.336,4.164c-2.402,0-4.371-0.932-5.586-1.836l-2.152,4.359c2.285,1.289,4.488,2.133,8.129,2.133
C32.176,41.305,36.613,37.328,36.613,32.357"/>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment