JavaScriptを使用してSVG URLに指定されたハッシュに基づいて線の色を変更するSVG(クロス)があります。
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<line x1="0" y1="0" x2="100%" y2="100%" stroke="black" stroke-width="1" />
<line x1="100%" y1="0" x2="0" y2="100%" stroke="black" stroke-width="1" />
<script>
if (window.location.hash) {
document.getElementsByTagName('line')[0].setAttribute('stroke', location.hash);
document.getElementsByTagName('line')[1].setAttribute('stroke', location.hash);
}
</script>
</svg>
これは<object>
要素 ( ) としては問題なく機能しますが、または css<object type="image/svg+xml" data="img/svg/cross.svg#ff0000"></object>
としては失敗します。img
background-image
これを CSS として機能させるにはどうすればよいbackground-image
ですか?