svgでロゴを書きたかったのですが、意外にも、で定義されたオブジェクトを再利用できないことがわかりました<defs>...</defs>
。Chromeで試してみました。
例を参照してください:
test1.htmlが機能せず、rectが描画されませんでした。
<!DOCTTYPE html> <html> <body> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="480" height="360"> <defs> <rect id="helo" x="0" y="0" height="20" width="20" /> </defs> <use xlink:href="#helo" /> </svg> </body> </html>
しかし、test2.svgは機能します。
<?xml version="1.0"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="480" height="360"> <defs> <rect id="helo" x="0" y="0" height="20" width="20" /> </defs> <use xlink:href="#helo" /> </svg>
test1.htmlを機能させるには何が必要ですか?どうもありがとう:)