0

背景をSVG画像として設定しようとしています。ただし、javascriptウィンドウ関数を使用してサイズを動的に構築する必要があります。これが論理です...

<script>
  function getWidth()
  {
    var w=window.innerWidth
    || document.documentElement.clientWidth
    || document.body.clientWidth;

    return w;

  }

  function getHeight()
  {
    var h=window.innerHeight
    || document.documentElement.clientHeight
    || document.body.clientHeight;

    return h;

  }

</script>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">

**var wid = getWidth();
  <rect width=wid height="100"**
  style="fill:rgb(0,0,255);stroke-width:1;stroke:rgb(0,0,0)"/>
</svg> 
4

1 に答える 1

0

CSS3がソリューションです。

html, body
{
    height: 100%;
}

body {
    background:url(../Images/books.svg);
    background-size:100% 100%;
    background-repeat:no-repeat;
}
于 2013-09-24T23:35:15.493 に答える